transaction

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Transactions in Minter are RLP-encoded structures.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	ChainID ChainID
}

func NewBuilder

func NewBuilder(chainID ChainID) *Builder

func (*Builder) NewTransaction

func (b *Builder) NewTransaction(data DataInterface) (Interface, error)
Example (SignMultiSignature1)
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	createMultisigData := transaction.NewCreateMultisigData().
		MustAddSigData("Mx08d920c5d93dbf23038fe1a54bbb34f41f77677c", 1).
		MustAddSigData("Mx6bf192730d01a19739b5030cdb6a60c992712a59", 3).
		MustAddSigData("Mx823bb524d5702addbe13086082f7f0310e07d176", 5).
		SetThreshold(7)

	multisigAddress := createMultisigData.AddressString()
	fmt.Println(multisigAddress)
	// Result: Mx0023aa9371e0779189ef5a7434456fc21a938945

	symbolMNT := "MNT"
	data, _ := transaction.NewSendData().
		SetCoin(symbolMNT).
		SetValue(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))).
		SetTo("Mx1b685a7c1e78726c48f619c497a07ed75fe00483")

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)

	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin(symbolMNT).SetSignatureType(transaction.SignatureTypeMulti).Sign(
		multisigAddress,
		"ae089b32e4e0976ca6888cb1023148bd1a9f1cc28c5d442e52e586754ff48d63",
		"b0a65cd84d57189b70d80fe0b3d5fa3ea6e02fa48041314a587a1f8fdba703d7",
		"4c8dbfb3258f383adf656c2131e5ed77ec482a36125db71fb49d29e0528ff2ba",
	)

	encode, _ := signedTx.Encode()
	fmt.Println(encode)
	// Result: 0xf901270102018a4d4e540000000000000001aae98a4d4e5400000000000000941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808002b8e8f8e6940023aa9371e0779189ef5a7434456fc21a938945f8cff8431ba0014aaffef58c3def74bbb828d7cba907df59b50a68749b8d90aa0d7520571be3a04397def13aa5a38b666d5ecf590af7fdec18663bfa448d517d6671fbe25cdde6f8431ba07bd81f68708141c01ed3bac914cc04dc07831989cb86c4b0e992ad9677bfa33aa03b0d936c268e080bbb85a70cfa6c48a88f023d9e06fa4ecfb9e3cb6659bc767af8431ba0767922509d65315ddf728da8cf5450fa8ba410680f7046405a1eeb7cf22f521aa01222a82c41f7ef51e5b6a64414078185393578f8a5373ac5f5a19ee512b9317b

}
Output:

Mx0023aa9371e0779189ef5a7434456fc21a938945
0xf901270102018a4d4e540000000000000001aae98a4d4e5400000000000000941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808002b8e8f8e6940023aa9371e0779189ef5a7434456fc21a938945f8cff8431ba0014aaffef58c3def74bbb828d7cba907df59b50a68749b8d90aa0d7520571be3a04397def13aa5a38b666d5ecf590af7fdec18663bfa448d517d6671fbe25cdde6f8431ba07bd81f68708141c01ed3bac914cc04dc07831989cb86c4b0e992ad9677bfa33aa03b0d936c268e080bbb85a70cfa6c48a88f023d9e06fa4ecfb9e3cb6659bc767af8431ba0767922509d65315ddf728da8cf5450fa8ba410680f7046405a1eeb7cf22f521aa01222a82c41f7ef51e5b6a64414078185393578f8a5373ac5f5a19ee512b9317b
Example (SignMultiSignature2)
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	symbolMNT := "MNT"
	data, _ := transaction.NewSendData().
		SetCoin(symbolMNT).
		SetValue(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))).
		SetTo("Mx1b685a7c1e78726c48f619c497a07ed75fe00483")

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	tx.SetNonce(1).SetGasPrice(1).SetGasCoin(symbolMNT).SetSignatureType(transaction.SignatureTypeMulti)

	signedTx1, _ := tx.Sign(
		"Mx0023aa9371e0779189ef5a7434456fc21a938945",
		"ae089b32e4e0976ca6888cb1023148bd1a9f1cc28c5d442e52e586754ff48d63",
	)
	signedTx2, _ := signedTx1.Sign(
		"Mx0023aa9371e0779189ef5a7434456fc21a938945",
		"b0a65cd84d57189b70d80fe0b3d5fa3ea6e02fa48041314a587a1f8fdba703d7",
	)
	signedTx3, _ := signedTx2.Sign(
		"Mx0023aa9371e0779189ef5a7434456fc21a938945",
		"4c8dbfb3258f383adf656c2131e5ed77ec482a36125db71fb49d29e0528ff2ba",
	)

	encode, _ := signedTx3.Encode()
	fmt.Println(encode)
}
Output:

0xf901270102018a4d4e540000000000000001aae98a4d4e5400000000000000941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808002b8e8f8e6940023aa9371e0779189ef5a7434456fc21a938945f8cff8431ba0014aaffef58c3def74bbb828d7cba907df59b50a68749b8d90aa0d7520571be3a04397def13aa5a38b666d5ecf590af7fdec18663bfa448d517d6671fbe25cdde6f8431ba07bd81f68708141c01ed3bac914cc04dc07831989cb86c4b0e992ad9677bfa33aa03b0d936c268e080bbb85a70cfa6c48a88f023d9e06fa4ecfb9e3cb6659bc767af8431ba0767922509d65315ddf728da8cf5450fa8ba410680f7046405a1eeb7cf22f521aa01222a82c41f7ef51e5b6a64414078185393578f8a5373ac5f5a19ee512b9317b
Example (SignMultiSignature3)
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	symbolMNT := "MNT"
	data, _ := transaction.NewSendData().
		SetCoin(symbolMNT).
		SetValue(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))).
		SetTo("Mx1b685a7c1e78726c48f619c497a07ed75fe00483")

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	tx.SetNonce(1).SetGasPrice(1).SetGasCoin(symbolMNT).SetSignatureType(transaction.SignatureTypeMulti)

	msigAddress := "Mx0023aa9371e0779189ef5a7434456fc21a938945"
	signedTx1, _ := tx.Clone().Sign(msigAddress, "ae089b32e4e0976ca6888cb1023148bd1a9f1cc28c5d442e52e586754ff48d63")
	signedTx2, _ := tx.Clone().Sign(msigAddress, "b0a65cd84d57189b70d80fe0b3d5fa3ea6e02fa48041314a587a1f8fdba703d7")
	signedTx3, _ := tx.Clone().Sign(msigAddress, "4c8dbfb3258f383adf656c2131e5ed77ec482a36125db71fb49d29e0528ff2ba")
	simpleSignatureData1, _ := signedTx1.SimpleSignatureData()
	simpleSignatureData2, _ := signedTx2.SimpleSignatureData()
	simpleSignatureData3, _ := signedTx3.SimpleSignatureData()
	signedTransaction, _ := tx.Clone().Sign(msigAddress)
	signedTx123, _ := signedTransaction.AddSignature(simpleSignatureData1, simpleSignatureData2, simpleSignatureData3)

	encode, _ := signedTx123.Encode()
	fmt.Println(encode)
}
Output:

0xf901270102018a4d4e540000000000000001aae98a4d4e5400000000000000941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808002b8e8f8e6940023aa9371e0779189ef5a7434456fc21a938945f8cff8431ba0014aaffef58c3def74bbb828d7cba907df59b50a68749b8d90aa0d7520571be3a04397def13aa5a38b666d5ecf590af7fdec18663bfa448d517d6671fbe25cdde6f8431ba07bd81f68708141c01ed3bac914cc04dc07831989cb86c4b0e992ad9677bfa33aa03b0d936c268e080bbb85a70cfa6c48a88f023d9e06fa4ecfb9e3cb6659bc767af8431ba0767922509d65315ddf728da8cf5450fa8ba410680f7046405a1eeb7cf22f521aa01222a82c41f7ef51e5b6a64414078185393578f8a5373ac5f5a19ee512b9317b
Example (SignSimple)
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(
		transaction.NewSendData().
			SetCoin("MNT").
			SetValue(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))).
			MustSetTo("Mx1b685a7c1e78726c48f619c497a07ed75fe00483"),
	)

	signedTransaction, _ := tx.
		SetGasPrice(1).
		SetGasCoin("MNT").
		SetNonce(1).
		Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")

	senderAddress, _ := signedTransaction.SenderAddress()
	fmt.Println(senderAddress)

	fee := signedTransaction.Fee().String()
	fmt.Println(fee)

	hash, _ := signedTransaction.Hash()
	fmt.Println(hash)

}
Output:

Mx622e1e0e788f4b1258f7e2a196f738c6a360c3de
10000000000000000
Mt13b73500c171006613fa8e82cc8b29857af1d63a34ca2cada95024bacca1670c

type BuyCoinData

type BuyCoinData struct {
	CoinToBuy          Coin
	ValueToBuy         *big.Int
	CoinToSell         Coin
	MaximumValueToSell *big.Int
}

Transaction for buy a coin paying another coin (owned by sender). CoinToBuy - Symbol of a coin to get. ValueToBuy - Amount of CoinToBuy to get. CoinToSell - Symbol of a coin to give. MaximumValueToSell - Maximum value of coins to sell.

func NewBuyCoinData

func NewBuyCoinData() *BuyCoinData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	data := transaction.NewBuyCoinData().
		SetCoinToBuy("TEST").
		SetValueToBuy(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))).
		SetCoinToSell("MNT").
		SetMaximumValueToSell(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil)))

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)

	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin("MNT").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf8830102018a4d4e540000000000000004a9e88a54455354000000000000880de0b6b3a76400008a4d4e5400000000000000880de0b6b3a7640000808001b845f8431ca04ee095a20ca58062a5758e2a6d3941857daa8943b5873c57f111190ca88dbc56a01148bf2fcc721ca353105e4f4a3419bec471d7ae08173f443a28c3ae6d27018a

func (*BuyCoinData) SetCoinToBuy

func (d *BuyCoinData) SetCoinToBuy(symbol string) *BuyCoinData

func (*BuyCoinData) SetCoinToSell

func (d *BuyCoinData) SetCoinToSell(symbol string) *BuyCoinData

func (*BuyCoinData) SetMaximumValueToSell

func (d *BuyCoinData) SetMaximumValueToSell(value *big.Int) *BuyCoinData

func (*BuyCoinData) SetValueToBuy

func (d *BuyCoinData) SetValueToBuy(value *big.Int) *BuyCoinData

type ChainID

type ChainID byte
const (
	MainNetChainID ChainID
	TestNetChainID
)

type Check added in v1.0.0

type Check struct {
	*CheckData
	// contains filtered or unexported fields
}

func (*Check) Encode added in v1.0.0

func (check *Check) Encode() (string, error)

func (*Check) SetPassphrase added in v1.0.0

func (check *Check) SetPassphrase(passphrase string) CheckInterface

Set secret phrase which you will pass to receiver of the check

func (*Check) Sign added in v1.0.0

func (check *Check) Sign(prKey string) (Signed, error)

Sign Check

type CheckAddress

type CheckAddress struct {
	// contains filtered or unexported fields
}

func NewCheckAddress

func NewCheckAddress(address string, passphrase string) (*CheckAddress, error)

func (*CheckAddress) Proof

func (check *CheckAddress) Proof() (string, error)

Proof Check

Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
)

func main() {
	check, _ := transaction.NewCheckAddress("Mxa7bc33954f1ce855ed1a8c768fdd32ed927def47", "pass")
	proof, _ := check.Proof()
	fmt.Println(proof)
}
Output:

da021d4f84728e0d3d312a18ec84c21768e0caa12a53cb0a1452771f72b0d1a91770ae139fd6c23bcf8cec50f5f2e733eabb8482cf29ee540e56c6639aac469600

type CheckData added in v1.0.0

type CheckData struct {
	Nonce    []byte
	ChainID  ChainID
	DueBlock uint64
	Coin     Coin
	Value    *big.Int
	GasCoin  Coin
	Lock     *big.Int
	V        *big.Int
	R        *big.Int
	S        *big.Int
}

Issue a check that will later be redeemed by the person of your choice.

func DecodeCheck added in v1.0.0

func DecodeCheck(rawCheck string) (*CheckData, error)

Prepare check string and convert to data

Example
package main

import (
	"encoding/hex"
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
)

func main() {
	data, _ := transaction.DecodeCheck("+K6DNDgwAoMPQj+KTU5UAAAAAAAAAIiKxyMEiegAAIpNTlQAAAAAAAAAuEFJfF8+b8GC/Rp5FSKp73V2cQvfvIb9vxZUdu8iDon5/xOA+T8tmi+S/asO3B4mBcwsabcHzUBLLLFSK3q6Te/VABugg8mUUWnwp7vllpc7MtyIdgh4BYCx07x7GIvts704VZSgR7LVNFlG7VSY9b7nE/hidqrARqX++CC+rud6m2+bwd8=")

	fmt.Println(string(data.Nonce))
	// Result: 480

	fmt.Println(data.ChainID)
	// Result: 2

	fmt.Println(data.Coin.String())
	// Result: MNT

	fmt.Println(data.DueBlock)
	// Result: 999999

	fmt.Println(data.Value.String())
	// Result: 10000000000000000000

	fmt.Println(data.Lock.String())
	//Result: 985283871505876742053353384809055983203325304659217336382177168476233943196356552072809135181493031263037291805582875144952622907359402361966594748392133888

	fmt.Println(data.V.Int64())
	// Result: 27

	fmt.Println(hex.EncodeToString(data.R.Bytes()))
	// Result: 83c9945169f0a7bbe596973b32dc887608780580b1d3bc7b188bedb3bd385594

	fmt.Println(hex.EncodeToString(data.S.Bytes()))
	// Result: 47b2d5345946ed5498f5bee713f86276aac046a5fef820beaee77a9b6f9bc1df

	sender, _ := data.Sender()
	fmt.Println(sender)
	// Result: Mxce931863b9c94a526d94acd8090c1c5955a6eb4b

}
Output:

480
2
MNT
999999
10000000000000000000
985283871505876742053353384809055983203325304659217336382177168476233943196356552072809135181493031263037291805582875144952622907359402361966594748392133888
27
83c9945169f0a7bbe596973b32dc887608780580b1d3bc7b188bedb3bd385594
47b2d5345946ed5498f5bee713f86276aac046a5fef820beaee77a9b6f9bc1df
Mxce931863b9c94a526d94acd8090c1c5955a6eb4b

func (*CheckData) PublicKey added in v1.0.0

func (check *CheckData) PublicKey() (string, error)

func (*CheckData) Sender added in v1.0.0

func (check *CheckData) Sender() (string, error)

func (*CheckData) String added in v1.0.0

func (check *CheckData) String() string

type CheckInterface added in v1.0.0

type CheckInterface interface {
	SetPassphrase(passphrase string) CheckInterface
	Sign(prKey string) (Signed, error)
}

func NewCheck added in v1.0.0

func NewCheck(nonce uint64, chainID ChainID, dueBlock uint64, coin string, value *big.Int, gasCoin string) CheckInterface

Create Check Nonce - unique "id" of the check. Coin Symbol - symbol of coin. Value - amount of coins. Due Block - defines last block height in which the check can be used.

Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	check := transaction.NewCheck(
		480,
		transaction.TestNetChainID,
		999999,
		"MNT",
		big.NewInt(0).Mul(big.NewInt(10), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil)),
		"MNT",
	).SetPassphrase("pass")

	sign, _ := check.Sign("64e27afaab363f21eec05291084367f6f1297a7b280d69d672febecda94a09ea")
	encode, _ := sign.Encode()
	fmt.Println(encode)
}
Output:

Mcf8ae8334383002830f423f8a4d4e5400000000000000888ac7230489e800008a4d4e5400000000000000b841497c5f3e6fc182fd1a791522a9ef7576710bdfbc86fdbf165476ef220e89f9ff1380f93f2d9a2f92fdab0edc1e2605cc2c69b707cd404b2cb1522b7aba4defd5001ba083c9945169f0a7bbe596973b32dc887608780580b1d3bc7b188bedb3bd385594a047b2d5345946ed5498f5bee713f86276aac046a5fef820beaee77a9b6f9bc1df

type Coin added in v1.0.5

type Coin [10]byte

func (Coin) String added in v1.0.5

func (c Coin) String() string

type CreateCoinData

type CreateCoinData struct {
	Name                 string
	Symbol               [20]byte
	InitialAmount        *big.Int
	InitialReserve       *big.Int
	ConstantReserveRatio uint
	MaxSupply            *big.Int
}

Transaction for creating new coin in a system. Name - Name of a coin. Arbitrary string up to 64 letters length. Symbol - Symbol of a coin. Must be unique, alphabetic, uppercase, 3 to 10 symbols length. InitialAmount - Amount of coins to issue. Issued coins will be available to sender account. InitialReserve - Initial reserve in BIP's. ConstantReserveRatio - CRR, uint, should be from 10 to 100.

func NewCreateCoinData

func NewCreateCoinData() *CreateCoinData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	data := transaction.NewCreateCoinData().
		SetName("SUPER TEST").
		SetSymbol("SPRTEST").
		SetInitialAmount(big.NewInt(0).Mul(big.NewInt(100), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))).
		SetInitialReserve(big.NewInt(0).Mul(big.NewInt(10), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))).
		SetConstantReserveRatio(10).
		SetMaxSupply(big.NewInt(0).Mul(big.NewInt(1000), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil)))

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)

	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin("MNT").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)

}
Output:

0xf8910102018a4d4e540000000000000005b7f68a535550455220544553548a5350525445535400000089056bc75e2d631000008a021e19e0c9bab24000000a893635c9adc5dea00000808001b845f8431ba07bf9c6916aabaac7fb34811b42350c0dbcfc6228cf2ce9b927254d01f9e0ec66a0039ea86546a950cd717544d9b19c30a5248cfeb0f93060145144b5bb511a4218

func (*CreateCoinData) SetConstantReserveRatio

func (d *CreateCoinData) SetConstantReserveRatio(ratio uint) *CreateCoinData

func (*CreateCoinData) SetInitialAmount

func (d *CreateCoinData) SetInitialAmount(value *big.Int) *CreateCoinData

func (*CreateCoinData) SetInitialReserve

func (d *CreateCoinData) SetInitialReserve(value *big.Int) *CreateCoinData

func (*CreateCoinData) SetMaxSupply added in v1.0.0

func (d *CreateCoinData) SetMaxSupply(maxSupply *big.Int) *CreateCoinData

func (*CreateCoinData) SetName

func (d *CreateCoinData) SetName(name string) *CreateCoinData

func (*CreateCoinData) SetSymbol

func (d *CreateCoinData) SetSymbol(symbol string) *CreateCoinData

type CreateMultisigData

type CreateMultisigData struct {
	Threshold uint
	Weights   []uint
	Addresses [][20]byte
}

func NewCreateMultisigData added in v0.2.5

func NewCreateMultisigData() *CreateMultisigData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
)

func main() {
	data := transaction.NewCreateMultisigData().
		MustAddSigData("Mx08d920c5d93dbf23038fe1a54bbb34f41f77677c", 1).
		MustAddSigData("Mx772fd5bd06356250e5efe572b6ae615860ee0c17", 3).
		MustAddSigData("Mx9c7f68ff71b5819c41e8f87cc99bdf6359da3d75", 5).
		SetThreshold(7)

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)

	msigAddress := data.AddressString()
	fmt.Println(msigAddress)
	// Result: Mxd43eef7b9406762aa031b82ed0b1082264a13934

	signedTx, _ := tx.SetNonce(11).SetGasPrice(1).SetGasCoin("MNT").SetSignatureType(transaction.SignatureTypeSingle).
		SetPayload([]byte(fmt.Sprintf("Multisig Address %s", msigAddress))).Sign("ae089b32e4e0976ca6888cb1023148bd1a9f1cc28c5d442e52e586754ff48d63")

	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
	// Result: 0xf901940b02018a4d4e54000000000000000cb848f84607c3010305f83f9408d920c5d93dbf23038fe1a54bbb34f41f77677c94772fd5bd06356250e5efe572b6ae615860ee0c17949c7f68ff71b5819c41e8f87cc99bdf6359da3d75b8f0616530383962333265346530393736636136383838636231303233313438626431613966316363323863356434343265353265353836373534666634386436332c20396437383839356661393534623262303766623366323964326165396635656230646330653932356136386566383336326534306334376261346164623330632c20376534303839633762363833663162386431383332613865393737636637396161343539626631373066663139363335343131323734373132346262643037322c204d78643433656566376239343036373632616130333162383265643062313038323236346131333933348001b845f8431ba03032390eb7457b987b223128b956e514c9847fda62c01b62672712719cca4edfa013d566aef3ba4729a2075ef0db8217e7ae390699be6bc959541d8d4b372219cf

}
Output:

Mxd43eef7b9406762aa031b82ed0b1082264a13934
0xf8df0b02018a4d4e54000000000000000cb848f84607c3010305f83f9408d920c5d93dbf23038fe1a54bbb34f41f77677c94772fd5bd06356250e5efe572b6ae615860ee0c17949c7f68ff71b5819c41e8f87cc99bdf6359da3d75b83b4d756c74697369672041646472657373204d78643433656566376239343036373632616130333162383265643062313038323236346131333933348001b845f8431ba00dc74e6b4f1b7e34ff06d106bf1b8d963d1538f55730761a88c4d35784fbccc8a05c758e30e1c535e15688bd1c2b240186485f02199f9e12a159fa06daf462ce15

func (*CreateMultisigData) AddSigData added in v1.0.0

func (d *CreateMultisigData) AddSigData(address string, weight uint) (*CreateMultisigData, error)

func (*CreateMultisigData) AddressBytes added in v1.0.0

func (d *CreateMultisigData) AddressBytes() [20]byte

func (*CreateMultisigData) AddressString added in v1.0.0

func (d *CreateMultisigData) AddressString() string

func (*CreateMultisigData) MustAddSigData added in v1.0.0

func (d *CreateMultisigData) MustAddSigData(address string, weight uint) *CreateMultisigData

func (*CreateMultisigData) SetThreshold added in v0.2.5

func (d *CreateMultisigData) SetThreshold(threshold uint) *CreateMultisigData

type DataInterface

type DataInterface interface {
	// contains filtered or unexported methods
}

type DeclareCandidacyData

type DeclareCandidacyData struct {
	Address    [20]byte
	PubKey     []byte
	Commission uint
	Coin       Coin
	Stake      *big.Int
}

Transaction for declaring new validator candidacy. Address - Address of candidate in Minter Network. This address would be able to control candidate. Also all rewards will be sent to this address. PubKey - Public key of a validator. Commission - Commission (from 0 to 100) from rewards which delegators will pay to validator. Coin - Symbol of coin to stake. Stake - Amount of coins to stake.

func NewDeclareCandidacyData

func NewDeclareCandidacyData() *DeclareCandidacyData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	data, _ := transaction.NewDeclareCandidacyData().
		MustSetPubKey("Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43").
		SetCommission(10).
		SetCoin("MNT").
		SetStake(big.NewInt(0).Mul(big.NewInt(5), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))).
		SetAddress("Mx9f7fd953c2c69044b901426831ed03ee0bd0597a")

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)

	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin("MNT").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf8a80102018a4d4e540000000000000006b84df84b949f7fd953c2c69044b901426831ed03ee0bd0597aa00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a430a8a4d4e5400000000000000884563918244f40000808001b845f8431ca06994a0bc24bb1a492db8d037d2f046f1436a6c166e59540db8de6230cc581e5ea03e5cdf8db2c7ef486438ef5fad3ccbdf5aa778a96de7bc22c2dc8b4e32a4a531

func (*DeclareCandidacyData) MustSetAddress

func (d *DeclareCandidacyData) MustSetAddress(address string) *DeclareCandidacyData

func (*DeclareCandidacyData) MustSetPubKey

func (d *DeclareCandidacyData) MustSetPubKey(key string) *DeclareCandidacyData

func (*DeclareCandidacyData) SetAddress

func (d *DeclareCandidacyData) SetAddress(address string) (*DeclareCandidacyData, error)

func (*DeclareCandidacyData) SetCoin

func (d *DeclareCandidacyData) SetCoin(symbol string) *DeclareCandidacyData

func (*DeclareCandidacyData) SetCommission

func (d *DeclareCandidacyData) SetCommission(value uint) *DeclareCandidacyData

func (*DeclareCandidacyData) SetPubKey

func (d *DeclareCandidacyData) SetPubKey(key string) (*DeclareCandidacyData, error)

func (*DeclareCandidacyData) SetStake

func (d *DeclareCandidacyData) SetStake(value *big.Int) *DeclareCandidacyData
type DeepLink struct {
	Type    Type
	Data    []byte
	Payload []byte

	Nonce    *uint // optional
	GasPrice *uint // optional
	GasCoin  *Coin // optional
}
func NewDeepLink(data DataInterface) (*DeepLink, error)
func (d *DeepLink) CreateLink(pass string) (string, error)

func (*DeepLink) Encode added in v0.2.0

func (d *DeepLink) Encode() (string, error)

func (*DeepLink) SetGasCoin added in v1.0.2

func (d *DeepLink) SetGasCoin(symbol string) *DeepLink

func (*DeepLink) SetPayload added in v0.2.0

func (d *DeepLink) SetPayload(payload []byte) *DeepLink

type DelegateData

type DelegateData struct {
	PubKey []byte
	Coin   Coin
	Value  *big.Int
}

Transaction for delegating funds to validator. PubKey - Public key of a validator. Coin - Symbol of coin to stake. Value - Amount of coins to stake.

func NewDelegateData

func NewDelegateData() *DelegateData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	data := transaction.NewDelegateData().
		MustSetPubKey("Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43").
		SetCoin("MNT").
		SetValue(big.NewInt(0).Mul(big.NewInt(10), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil)))

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin("MNT").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
	// Result: 0xf8900102018a4d4e540000000000000007b6f5a00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a438a4d4e5400000000000000888ac7230489e80000808001b845f8431ca0a77d4b04fb9f3b6601c28369a0c02b7a2bb5d2dd0efac5388705513b0c298f9ca076044f1fb751aff727a41959dc31336c1c6bb0751bfb8c1ef05efb027e718fc2

}
Output:

0xf8900102018a4d4e540000000000000007b6f5a00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a438a4d4e5400000000000000888ac7230489e80000808001b845f8431ca0a77d4b04fb9f3b6601c28369a0c02b7a2bb5d2dd0efac5388705513b0c298f9ca076044f1fb751aff727a41959dc31336c1c6bb0751bfb8c1ef05efb027e718fc2

func (*DelegateData) MustSetPubKey

func (d *DelegateData) MustSetPubKey(key string) *DelegateData

func (*DelegateData) SetCoin

func (d *DelegateData) SetCoin(symbol string) *DelegateData

func (*DelegateData) SetPubKey

func (d *DelegateData) SetPubKey(key string) (*DelegateData, error)

func (*DelegateData) SetValue added in v0.2.3

func (d *DelegateData) SetValue(value *big.Int) *DelegateData

type EditCandidateData

type EditCandidateData struct {
	PubKey         []byte
	RewardAddress  [20]byte
	OwnerAddress   [20]byte
	ControlAddress [20]byte
}

Transaction for editing existing candidate.

func NewEditCandidateData

func NewEditCandidateData() *EditCandidateData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
)

func main() {
	data := transaction.NewEditCandidateData().
		MustSetPubKey("Mp4ae1ee73e6136c85b0ca933a9a1347758a334885f10b3238398a67ac2eb153b8").
		MustSetOwnerAddress("Mxe731fcddd37bb6e72286597d22516c8ba3ddffa0").
		MustSetRewardAddress("Mx89e5dc185e6bab772ac8e00cf3fb3f4cb0931c47")

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)

	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin("MNT").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf8a80102018a4d4e54000000000000000eb84df84ba04ae1ee73e6136c85b0ca933a9a1347758a334885f10b3238398a67ac2eb153b89489e5dc185e6bab772ac8e00cf3fb3f4cb0931c4794e731fcddd37bb6e72286597d22516c8ba3ddffa0808001b845f8431ba01408280f2cb444eb9b150026992eeaf0cf10fc64ac5dad77ec8bd87ff7ffb02ca03947d22bd5c50f5ddba4ccf2c62dcf3aa99a78913c01069aa300c04fa6a99018

func (*EditCandidateData) MustSetOwnerAddress

func (d *EditCandidateData) MustSetOwnerAddress(address string) *EditCandidateData

func (*EditCandidateData) MustSetPubKey

func (d *EditCandidateData) MustSetPubKey(key string) *EditCandidateData

func (*EditCandidateData) MustSetRewardAddress

func (d *EditCandidateData) MustSetRewardAddress(address string) *EditCandidateData

func (*EditCandidateData) SetOwnerAddress

func (d *EditCandidateData) SetOwnerAddress(address string) (*EditCandidateData, error)

func (*EditCandidateData) SetPubKey

func (d *EditCandidateData) SetPubKey(key string) (*EditCandidateData, error)

func (*EditCandidateData) SetRewardAddress

func (d *EditCandidateData) SetRewardAddress(address string) (*EditCandidateData, error)

type EditCandidatePublicKeyData added in v1.1.7

type EditCandidatePublicKeyData struct {
	PubKey    [32]byte // Public key of a validator
	NewPubKey [32]byte // New public key for change.
}

EditCandidatePublicKeyData is Data of Transaction for editing candidate public key.

func NewEditCandidatePublicKeyData added in v1.1.7

func NewEditCandidatePublicKeyData() *EditCandidatePublicKeyData

NewEditCandidatePublicKeyData returns new EditCandidatePublicKeyData of Transaction for editing existing candidate.

func (*EditCandidatePublicKeyData) MustSetNewPubKey added in v1.1.7

MustSetNewPubKey tries to set new public key and panics on error.

func (*EditCandidatePublicKeyData) MustSetPubKey added in v1.1.7

MustSetPubKey tries to set public key of validator and panics on error.

func (*EditCandidatePublicKeyData) SetNewPubKey added in v1.1.7

SetNewPubKey sets new public key for change.

func (*EditCandidatePublicKeyData) SetPubKey added in v1.1.7

SetPubKey sets public key of a validator.

func (*EditCandidatePublicKeyData) Type added in v1.1.7

func (d *EditCandidatePublicKeyData) Type() Type

Type returns Data type of the transaction.

type EditCoinOwnerData added in v1.1.7

type EditCoinOwnerData struct {
	Symbol   Coin
	NewOwner [20]byte
}

EditCoinOwnerData is a Data of Transaction for editing coin owner.

func NewEditCoinOwnerData added in v1.1.7

func NewEditCoinOwnerData() *EditCoinOwnerData

NewEditCoinOwnerData returns new EditCoinOwnerData of Transaction for editing coin owner.

func (*EditCoinOwnerData) MustSetNewOwner added in v1.1.7

func (d *EditCoinOwnerData) MustSetNewOwner(address string) *EditCoinOwnerData

MustSetNewOwner tries to set address of candidate and panics on error.

func (*EditCoinOwnerData) SetNewOwner added in v1.1.7

func (d *EditCoinOwnerData) SetNewOwner(address string) (*EditCoinOwnerData, error)

SetNewOwner sets new owner address of a coin.

func (*EditCoinOwnerData) SetSymbol added in v1.1.7

func (d *EditCoinOwnerData) SetSymbol(symbol string) *EditCoinOwnerData

SetSymbol sets symbol of a coin.

func (*EditCoinOwnerData) Type added in v1.1.7

func (d *EditCoinOwnerData) Type() Type

Type returns Data type of the transaction.

type EditMultisigData added in v1.1.7

type EditMultisigData struct {
	Threshold uint       // Threshold for the sums of signature weights.
	Weights   []uint     // Weights of signers
	Addresses [][20]byte // List of signed addresses
}

EditMultisigData is a Data of Transaction for edit multisig.

func NewEditMultisigData added in v1.1.7

func NewEditMultisigData() *EditMultisigData

NewEditMultisigData returns new EditMultisigData of Transaction for edit multisig.

func (*EditMultisigData) AddSigData added in v1.1.7

func (d *EditMultisigData) AddSigData(address string, weight uint) (*EditMultisigData, error)

AddSigData sets a set of signers with appropriate weights.

func (*EditMultisigData) MustAddSigData added in v1.1.7

func (d *EditMultisigData) MustAddSigData(address string, weight uint) *EditMultisigData

MustAddSigData tries to set a set of signers with appropriate weights and panics on error.

func (*EditMultisigData) SetThreshold added in v1.1.7

func (d *EditMultisigData) SetThreshold(threshold uint) *EditMultisigData

SetThreshold sets threshold for the sums of signature weights.

func (*EditMultisigData) Type added in v1.1.7

func (d *EditMultisigData) Type() Type

Type returns Data type of the transaction.

type EncodeInterface added in v1.0.0

type EncodeInterface interface {
	Encode() (string, error)
}

type Interface

type Interface interface {
	EncodeInterface

	SetSignatureType(signatureType SignatureType) Interface
	SetMultiSignatureType() Interface

	SetNonce(nonce uint64) Interface
	SetGasCoin(name string) Interface
	SetGasPrice(price uint8) Interface
	SetPayload(payload []byte) Interface
	SetServiceData(serviceData []byte) Interface
	Sign(key string, multisigPrKeys ...string) (SignedTransaction, error)
	Clone() Interface
	// contains filtered or unexported methods
}

type MultisendData

type MultisendData struct {
	List []MultisendDataItem
}

Transaction for sending coins to multiple addresses.

func NewMultisendData

func NewMultisendData() *MultisendData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	symbolMNT := "MNT"
	data := transaction.NewMultisendData().AddItem(
		*transaction.NewMultisendDataItem().
			SetCoin(symbolMNT).
			SetValue(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18-1), nil))).
			MustSetTo("Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99"),
	).AddItem(
		*transaction.NewMultisendDataItem().
			SetCoin(symbolMNT).
			SetValue(big.NewInt(0).Mul(big.NewInt(2), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18-1), nil))).
			MustSetTo("Mxddab6281766ad86497741ff91b6b48fe85012e3c"),
	)

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin(symbolMNT).Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf8b30102018a4d4e54000000000000000db858f856f854e98a4d4e540000000000000094fe60014a6e9ac91618f5d1cab3fd58cded61ee9988016345785d8a0000e98a4d4e540000000000000094ddab6281766ad86497741ff91b6b48fe85012e3c8802c68af0bb140000808001b845f8431ca0b15dcf2e013df1a2aea02e36a17af266d8ee129cdcb3e881d15b70c9457e7571a0226af7bdaca9d42d6774c100b22e0c7ba4ec8dd664d17986318e905613013283

func (*MultisendData) AddItem

func (d *MultisendData) AddItem(item MultisendDataItem) *MultisendData

type MultisendDataItem

type MultisendDataItem SendData

func NewMultisendDataItem

func NewMultisendDataItem() *MultisendDataItem

func (*MultisendDataItem) MustSetTo

func (d *MultisendDataItem) MustSetTo(address string) *MultisendDataItem

func (*MultisendDataItem) SetCoin

func (d *MultisendDataItem) SetCoin(symbol string) *MultisendDataItem

func (*MultisendDataItem) SetTo

func (d *MultisendDataItem) SetTo(address string) (*MultisendDataItem, error)

func (*MultisendDataItem) SetValue

func (d *MultisendDataItem) SetValue(value *big.Int) *MultisendDataItem

type PriceVoteData added in v1.1.7

type PriceVoteData struct {
	Price uint
}

func NewPriceVoteData added in v1.1.7

func NewPriceVoteData() *PriceVoteData

func (*PriceVoteData) SetPrice added in v1.1.7

func (d *PriceVoteData) SetPrice(price uint) *PriceVoteData

func (*PriceVoteData) Type added in v1.1.7

func (d *PriceVoteData) Type() Type

Type returns Data type of the transaction.

type RecreateCoinData added in v1.1.7

type RecreateCoinData struct {
	Name                 string   // Name of a coin
	Symbol               [20]byte // Symbol of a coin. Must be unique, alphabetic, uppercase, 3 to 10 symbols length
	InitialAmount        *big.Int // Amount of coins to issue. Issued coins will be available to sender account. Should be between 1 and 1,000,000,000,000,000 coins.
	InitialReserve       *big.Int // Initial reserve in BIP's
	ConstantReserveRatio uint     // ConstantReserveRatio (CRR), should be from 10 to 100.
	MaxSupply            *big.Int // Max amount of coins that are allowed to be issued. Maximum is 1,000,000,000,000,000
}

RecreateCoinData is a Data of Transaction for recreating new coin.

func NewRecreateCoinData added in v1.1.7

func NewRecreateCoinData() *RecreateCoinData

NewRecreateCoinData returns new RecreateCoinData of Transaction for recreating coin

func (*RecreateCoinData) SetConstantReserveRatio added in v1.1.7

func (d *RecreateCoinData) SetConstantReserveRatio(ratio uint) *RecreateCoinData

SetConstantReserveRatio sets CRR, uint, should be from 10 to 100.

func (*RecreateCoinData) SetInitialAmount added in v1.1.7

func (d *RecreateCoinData) SetInitialAmount(value *big.Int) *RecreateCoinData

SetInitialAmount sets amount of coins to issue. Issued coins will be available to sender account.

func (*RecreateCoinData) SetInitialReserve added in v1.1.7

func (d *RecreateCoinData) SetInitialReserve(value *big.Int) *RecreateCoinData

SetInitialReserve sets initial reserve in BIP's.

func (*RecreateCoinData) SetMaxSupply added in v1.1.7

func (d *RecreateCoinData) SetMaxSupply(maxSupply *big.Int) *RecreateCoinData

SetMaxSupply sets maximum amount of coins that are allowed to be issued.

func (*RecreateCoinData) SetName added in v1.1.7

func (d *RecreateCoinData) SetName(name string) *RecreateCoinData

SetName sets name of a coin. Arbitrary string up to 64 letters length.

func (*RecreateCoinData) SetSymbol added in v1.1.7

func (d *RecreateCoinData) SetSymbol(symbol string) *RecreateCoinData

SetSymbol sets symbol of a coin. Must be unique, alphabetic, uppercase, 3 to 10 symbols length.

func (*RecreateCoinData) Type added in v1.1.7

func (d *RecreateCoinData) Type() Type

Type returns Data type of the transaction.

type RedeemCheckData

type RedeemCheckData struct {
	RawCheck []byte
	Proof    [65]byte
}

Transaction for redeeming a check. RawCheck - Raw check received from sender. Proof - Proof of owning a check. Note that maximum GasPrice is limited to 1 to prevent fraud, because GasPrice is set by redeem tx sender but commission is charded from check issuer.

func NewRedeemCheckData

func NewRedeemCheckData() *RedeemCheckData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
)

func main() {
	data := transaction.NewRedeemCheckData().
		MustSetProof("da021d4f84728e0d3d312a18ec84c21768e0caa12a53cb0a1452771f72b0d1a91770ae139fd6c23bcf8cec50f5f2e733eabb8482cf29ee540e56c6639aac469600").
		MustSetRawCheck("Mcf89b01830f423f8a4d4e5400000000000000843b9aca00b8419b3beac2c6ad88a8bd54d24912754bb820e58345731cb1b9bc0885ee74f9e50a58a80aa990a29c98b05541b266af99d3825bb1e5ed4e540c6e2f7c9b40af9ecc011ca00f7ba6d0aa47d74274b960fba02be03158d0374b978dcaa5f56fc7cf1754f821a019a829a3b7bba2fc290f5c96e469851a3876376d6a6a4df937327b3a5e9e8297")

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin("MNT").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf8910102018a4d4e540000000000000005b7f68a535550455220544553548a5350525445535400000089056bc75e2d631000008a021e19e0c9bab24000000a893635c9adc5dea00000808001b845f8431ba07bf9c6916aabaac7fb34811b42350c0dbcfc6228cf2ce9b927254d01f9e0ec66a0039ea86546a950cd717544d9b19c30a5248cfeb0f93060145144b5bb511a4218

func (*RedeemCheckData) MustSetProof

func (d *RedeemCheckData) MustSetProof(proof string) *RedeemCheckData

func (*RedeemCheckData) MustSetRawCheck

func (d *RedeemCheckData) MustSetRawCheck(raw string) *RedeemCheckData

func (*RedeemCheckData) SetProof

func (d *RedeemCheckData) SetProof(proof string) (*RedeemCheckData, error)

func (*RedeemCheckData) SetRawCheck

func (d *RedeemCheckData) SetRawCheck(raw string) (*RedeemCheckData, error)

type SellAllCoinData

type SellAllCoinData struct {
	CoinToSell        Coin
	CoinToBuy         Coin
	MinimumValueToBuy *big.Int
}

Transaction for selling one coin (owned by sender) in favour of another coin in a system. CoinToSell - Symbol of a coin to give. ValueToSell - Amount of CoinToSell to give. CoinToBuy - Symbol of a coin to get. MinimumValueToBuy - Minimum value of coins to get.

func NewSellAllCoinData

func NewSellAllCoinData() *SellAllCoinData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	data := transaction.NewSellAllCoinData().
		SetCoinToSell("MNT").
		SetCoinToBuy("TEST").
		SetMinimumValueToBuy(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil)))

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin("MNT").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf87a0102018a4d4e540000000000000003a0df8a4d4e54000000000000008a54455354000000000000880de0b6b3a7640000808001b845f8431ca0b10794a196b6ad2f94e6162613ca9538429dd49ca493594ba9d99f80d2499765a03c1d78e9e04f57336691e8812a16faccb00bf92ac817ab61cd9bf001e9380d47

func (*SellAllCoinData) SetCoinToBuy

func (d *SellAllCoinData) SetCoinToBuy(symbol string) *SellAllCoinData

func (*SellAllCoinData) SetCoinToSell

func (d *SellAllCoinData) SetCoinToSell(symbol string) *SellAllCoinData

func (*SellAllCoinData) SetMinimumValueToBuy

func (d *SellAllCoinData) SetMinimumValueToBuy(value *big.Int) *SellAllCoinData

type SellCoinData

type SellCoinData struct {
	CoinToSell        Coin
	ValueToSell       *big.Int
	CoinToBuy         Coin
	MinimumValueToBuy *big.Int
}

Transaction for selling one coin (owned by sender) in favour of another coin in a system. CoinToSell - Symbol of a coin to give. ValueToSell - Amount of CoinToSell to give. CoinToBuy - Symbol of a coin to get. MinimumValueToBuy - Minimum value of coins to get.

func NewSellCoinData

func NewSellCoinData() *SellCoinData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	data := transaction.NewSellCoinData().
		SetCoinToSell("MNT").
		SetValueToSell(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))).
		SetCoinToBuy("TEST").
		SetMinimumValueToBuy(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil)))
	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin("MNT").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf8830102018a4d4e540000000000000002a9e88a4d4e5400000000000000880de0b6b3a76400008a54455354000000000000880de0b6b3a7640000808001b845f8431ba0e34be907a18acb5a1aed263ef419f32f5adc6e772b92f949906b497bba557df3a0291d7704980994f7a6f5950ca84720746b5928f21c3cfc5a5fbca2a9f4d35db0

func (*SellCoinData) SetCoinToBuy

func (d *SellCoinData) SetCoinToBuy(symbol string) *SellCoinData

func (*SellCoinData) SetCoinToSell

func (d *SellCoinData) SetCoinToSell(symbol string) *SellCoinData

func (*SellCoinData) SetMinimumValueToBuy

func (d *SellCoinData) SetMinimumValueToBuy(value *big.Int) *SellCoinData

func (*SellCoinData) SetValueToSell

func (d *SellCoinData) SetValueToSell(value *big.Int) *SellCoinData

type SendData

type SendData struct {
	Coin  Coin
	To    [20]byte
	Value *big.Int
}

Transaction for sending arbitrary coin. Coin - Symbol of a coin. To - Recipient address in Minter Network. Value - Amount of Coin to send.

func NewSendData

func NewSendData() *SendData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	value := big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))
	address := "Mx1b685a7c1e78726c48f619c497a07ed75fe00483"
	symbolMNT := "MNT"
	data, _ := transaction.NewSendData().
		SetCoin(symbolMNT).
		SetValue(value).
		SetTo(address)

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin("MNT").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf8840102018a4d4e540000000000000001aae98a4d4e5400000000000000941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808001b845f8431ca01f36e51600baa1d89d2bee64def9ac5d88c518cdefe45e3de66a3cf9fe410de4a01bc2228dc419a97ded0efe6848de906fbe6c659092167ef0e7dcb8d15024123a

func (*SendData) MustSetTo

func (d *SendData) MustSetTo(address string) *SendData

func (*SendData) SetCoin

func (d *SendData) SetCoin(symbol string) *SendData

func (*SendData) SetTo

func (d *SendData) SetTo(address string) (*SendData, error)

func (*SendData) SetValue

func (d *SendData) SetValue(value *big.Int) *SendData

type SetCandidateOffData

type SetCandidateOffData struct {
	PubKey []byte
}

Transaction for turning candidate off. This transaction should be sent from address which is set in the "Declare candidacy transaction". PubKey - Public key of a validator.

func NewSetCandidateOffData

func NewSetCandidateOffData() *SetCandidateOffData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
)

func main() {
	data := transaction.NewSetCandidateOffData().
		MustSetPubKey("Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43")

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin("MNT").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf87b0102018a4d4e54000000000000000ba2e1a00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43808001b844f8421ba0691f8353018ff13d13b4ffe19dc70a629eb51d9e2e18aa565aa94a6f66ff57ae9fc678a3f99445d63e8a4b75a05f4f6844c5b553c1c10dc663324bbbba15cca3

func (*SetCandidateOffData) MustSetPubKey

func (d *SetCandidateOffData) MustSetPubKey(key string) *SetCandidateOffData

func (*SetCandidateOffData) SetPubKey

func (d *SetCandidateOffData) SetPubKey(key string) (*SetCandidateOffData, error)

type SetCandidateOnData

type SetCandidateOnData struct {
	PubKey []byte
}

Transaction for turning candidate on. This transaction should be sent from address which is set in the "Declare candidacy transaction". PubKey - Public key of a validator.

func NewSetCandidateOnData

func NewSetCandidateOnData() *SetCandidateOnData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
)

func main() {
	data := transaction.NewSetCandidateOnData().
		MustSetPubKey("Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43")
	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin("MNT").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf87c0102018a4d4e54000000000000000aa2e1a00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43808001b845f8431ca02805b168a927a0d50f7d64828a65b3ed57d3e0afa132ebd5be7337d892c123a9a03294e6f8c8522835fceb9981a8e06eed45e96781bfa4996267e80763e6060b4b

func (*SetCandidateOnData) MustSetPubKey

func (d *SetCandidateOnData) MustSetPubKey(key string) *SetCandidateOnData

func (*SetCandidateOnData) SetPubKey

func (d *SetCandidateOnData) SetPubKey(key string) (*SetCandidateOnData, error)

type SetHaltBlockData added in v1.1.7

type SetHaltBlockData struct {
	PubKey [32]byte
	Height uint64
}

SetHaltBlockData is a Data of Transaction for

func NewSetHaltBlockData added in v1.1.7

func NewSetHaltBlockData() *SetHaltBlockData

NewSetHaltBlockData returns new SetHaltBlockData of Transaction for

func (*SetHaltBlockData) MustSetPubKey added in v1.1.7

func (d *SetHaltBlockData) MustSetPubKey(key string) *SetHaltBlockData

MustSetPubKey tries to set public key and panics on error.

func (*SetHaltBlockData) SetHeight added in v1.1.7

func (d *SetHaltBlockData) SetHeight(height uint64) *SetHaltBlockData

SetHeight sets height

func (*SetHaltBlockData) SetPubKey added in v1.1.7

func (d *SetHaltBlockData) SetPubKey(key string) (*SetHaltBlockData, error)

SetPubKey sets public key.

func (*SetHaltBlockData) Type added in v1.1.7

func (d *SetHaltBlockData) Type() Type

Type returns Data type of the transaction.

type Signature

type Signature struct {
	V *big.Int
	R *big.Int
	S *big.Int
}

type SignatureMulti added in v1.0.0

type SignatureMulti struct {
	Multisig   [20]byte
	Signatures []*Signature
}

type SignatureType

type SignatureType byte
const (
	SignatureTypeSingle SignatureType
	SignatureTypeMulti
)

type Signed

type Signed interface {
	Encode() (string, error)
}

type SignedTransaction

type SignedTransaction interface {
	EncodeInterface
	GetTransaction() *Transaction
	Fee() *big.Int
	Hash() (string, error)
	Data() DataInterface
	Signature() (signatureInterface, error)
	AddSignature(signatures ...[]byte) (SignedTransaction, error)
	SignatureData() []byte
	SimpleSignatureData() ([]byte, error)
	SenderAddress() (string, error)
	Sign(prKey string, multisigPrKeys ...string) (SignedTransaction, error)
}

func Decode

func Decode(tx string) (SignedTransaction, error)

Decode transaction

type Transaction

type Transaction struct {
	Nonce         uint64
	ChainID       ChainID
	GasPrice      uint8
	GasCoin       Coin
	Type          Type
	Data          []byte
	Payload       []byte
	ServiceData   []byte
	SignatureType SignatureType
	SignatureData []byte
}

type Type

type Type byte

Type of transaction is determined by a single byte.

const (
	TypeSend Type
	TypeSellCoin
	TypeSellAllCoin
	TypeBuyCoin
	TypeCreateCoin
	TypeDeclareCandidacy
	TypeDelegate
	TypeUnbond
	TypeRedeemCheck
	TypeSetCandidateOnline
	TypeSetCandidateOffline
	TypeCreateMultisig
	TypeMultisend
	TypeEditCandidate
	TypeSetHaltBlock
	TypeRecreateCoin
	TypeEditCoinOwner
	TypeEditMultisig
	TypePriceVote
	TypeEditCandidatePublicKey
)

type UnbondData

type UnbondData struct {
	PubKey []byte
	Coin   Coin
	Value  *big.Int
}

Transaction for unbonding funds from validator's stake. PubKey - Public key of a validator. Coin - Symbol of coin to stake. Value - Amount of coins to stake.

func NewUnbondData

func NewUnbondData() *UnbondData
Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/transaction"
	"math/big"
)

func main() {
	data := transaction.NewUnbondData().
		MustSetPubKey("Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43").
		SetCoin("MNT").
		SetValue(big.NewInt(0).Mul(big.NewInt(10), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil)))

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin("MNT").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf8900102018a4d4e540000000000000008b6f5a00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a438a4d4e5400000000000000888ac7230489e80000808001b845f8431ca01d103930ab6ba067bb0ea4ac67d520a7eb6b2cc547860404a194777a7772659aa04b3968aa5a8455fe1ddc09b6a850624b27ce9acafac8962a90b438ab8d963439

func (*UnbondData) MustSetPubKey

func (d *UnbondData) MustSetPubKey(key string) *UnbondData

func (*UnbondData) SetCoin

func (d *UnbondData) SetCoin(symbol string) *UnbondData

func (*UnbondData) SetPubKey

func (d *UnbondData) SetPubKey(key string) (*UnbondData, error)

func (*UnbondData) SetValue

func (d *UnbondData) SetValue(value *big.Int) *UnbondData

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL