transaction

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 15 Imported by: 16

Documentation

Overview

Package transaction is a guide and assistant in working with fields and types of transactions,creating signatures, encoding and decoding with RLP.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BipToPip

func BipToPip(bip *big.Int) *big.Int

BipToPip converts BIP to PIP (multiplies input by 1e18)

func FloatBipToPip added in v2.4.0

func FloatBipToPip(bip float64) *big.Int

FloatBipToPip converts BIP to PIP (multiplies input by 1e18)

func IsValidBigInt added in v2.4.0

func IsValidBigInt(s string) bool

IsValidBigInt verifies that string is a valid int

func MaxCoinSupply added in v2.2.0

func MaxCoinSupply() *big.Int

MaxCoinSupply returns max available coin supply

func MultisigAddress

func MultisigAddress(owner string, nonce uint64) string

MultisigAddress returns multisig address created by the sender at the block height.

func StringToBigInt added in v2.4.0

func StringToBigInt(s string) *big.Int

StringToBigInt converts string to BigInt, panics on empty strings and errors

Types

type AddLimitOrderData added in v2.4.0

type AddLimitOrderData struct {
	CoinToSell  CoinID   // ID of a coin to sell
	ValueToSell *big.Int // Amount of CoinToSell to sell
	CoinToBuy   CoinID   // ID of a coin to buy
	ValueToBuy  *big.Int // Amount of CoinToSell to buy
}

AddLimitOrderData is a Data of Transaction for setting orders for sale in liquidity pool.

func NewAddLimitOrderData added in v2.4.0

func NewAddLimitOrderData() *AddLimitOrderData

func (*AddLimitOrderData) Encode added in v2.4.0

func (d *AddLimitOrderData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*AddLimitOrderData) SetCoinToBuy added in v2.4.0

func (d *AddLimitOrderData) SetCoinToBuy(coin CoinID) *AddLimitOrderData

SetCoinToBuy sets ...

func (*AddLimitOrderData) SetCoinToSell added in v2.4.0

func (d *AddLimitOrderData) SetCoinToSell(coin CoinID) *AddLimitOrderData

SetCoinToSell sets ...

func (*AddLimitOrderData) SetValueToBuy added in v2.4.0

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

SetValueToBuy sets value to buy

func (*AddLimitOrderData) SetValueToSell added in v2.4.0

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

SetValueToSell sets value to sell

func (*AddLimitOrderData) Type added in v2.4.0

func (d *AddLimitOrderData) Type() Type

Type returns Data type of the transaction.

type AddLiquidityData added in v2.2.0

type AddLiquidityData struct {
	Coin0          CoinID   // ID of first coin to pair
	Coin1          CoinID   // ID of second coin to pair
	Volume0        *big.Int // Volume to add to reserve of the swap pool of first coin
	MaximumVolume1 *big.Int // Maximum volume to add to reserve of the swap pool of second coin
}

AddLiquidityData is a Data of Transaction for to add reserves of a pair of coins to the pool. To create liquidity through this pool.

func NewAddLiquidityData added in v2.2.0

func NewAddLiquidityData() *AddLiquidityData

NewAddLiquidityData creates AddLiquidityData

func (*AddLiquidityData) Encode added in v2.2.0

func (d *AddLiquidityData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*AddLiquidityData) SetCoin0 added in v2.2.0

func (d *AddLiquidityData) SetCoin0(id uint64) *AddLiquidityData

SetCoin0 sets first ID of coin to pair

func (*AddLiquidityData) SetCoin1 added in v2.2.0

func (d *AddLiquidityData) SetCoin1(id uint64) *AddLiquidityData

SetCoin1 sets second ID of coin to pair

func (*AddLiquidityData) SetMaximumVolume1 added in v2.2.0

func (d *AddLiquidityData) SetMaximumVolume1(maximumVolume1 *big.Int) *AddLiquidityData

SetMaximumVolume1 sets maximum volume to add to reserve of the swap pool of second coin

func (*AddLiquidityData) SetVolume0 added in v2.2.0

func (d *AddLiquidityData) SetVolume0(value0 *big.Int) *AddLiquidityData

SetVolume0 sets volume to add to reserve of the swap pool of first coin

func (*AddLiquidityData) Type added in v2.2.0

func (d *AddLiquidityData) Type() Type

Type returns Data type of the transaction.

type Address

type Address [20]byte

Address is address.

func (*Address) String

func (a *Address) String() string

String returns Address as string.

type Builder

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

Builder is creator of Transaction.

func NewBuilder

func NewBuilder(chainID ChainID) *Builder

NewBuilder returns new Builder for creating Transaction.

func (*Builder) NewTransaction

func (b *Builder) NewTransaction(data Data) (Interface, error)

NewTransaction returns new transaction with Data.

Example (SignMultiSignatureAddSignature)

You can collect all signatures in one place without revealing the private key.

package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data, _ := transaction.NewSendData().
		SetCoin(1).
		SetValue(transaction.BipToPip(big.NewInt(1))).
		SetTo("Mx1b685a7c1e78726c48f619c497a07ed75fe00483")

	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	tx.SetNonce(1).SetGasPrice(1).SetGasCoin(1).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.SingleSignatureData()
	simpleSignatureData2, _ := signedTx2.SingleSignatureData()
	simpleSignatureData3, _ := signedTx3.SingleSignatureData()
	signedTransaction, _ := tx.Clone().Sign(msigAddress)
	signedTx123, _ := signedTransaction.AddSignature(simpleSignatureData1, simpleSignatureData2, simpleSignatureData3)

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

0xf901130102010101a0df01941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808002b8e8f8e6940023aa9371e0779189ef5a7434456fc21a938945f8cff8431ca07dd407fa5d2a161581d03cdeb7c94fcd5ade47d376af75f2c92d1483f821fe2ca00d16b6cdbceaadcd0fd72bd39ee17841871da333a571535fccfbcf6285881c2af8431ba07c2d063126024a1e19363e7e254312ca9ab37795b06102da25bd1c0dec81a934a043b7bec83db41c594ac7a8d416fca2f83f0e65ada1221fe659ba4dbe1f3c921af8431ba09318e56a242c39c10ce87ab51d10322cc62cf23885867bc89a24e8c3fa8483e9a04c82c1224d1b4efa7fba06623da2896745ce444d35ed77973759e6404b66bb95
Example (SignMultiSignature_dynamically_adding_private_keys)

You can transfer the transaction to the remaining addresses.

package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data, _ := transaction.NewSendData().
		SetCoin(1).
		SetValue(transaction.BipToPip(big.NewInt(1))).
		SetTo("Mx1b685a7c1e78726c48f619c497a07ed75fe00483")

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

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

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

0xf901130102010101a0df01941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808002b8e8f8e6940023aa9371e0779189ef5a7434456fc21a938945f8cff8431ca07dd407fa5d2a161581d03cdeb7c94fcd5ade47d376af75f2c92d1483f821fe2ca00d16b6cdbceaadcd0fd72bd39ee17841871da333a571535fccfbcf6285881c2af8431ba07c2d063126024a1e19363e7e254312ca9ab37795b06102da25bd1c0dec81a934a043b7bec83db41c594ac7a8d416fca2f83f0e65ada1221fe659ba4dbe1f3c921af8431ba09318e56a242c39c10ce87ab51d10322cc62cf23885867bc89a24e8c3fa8483e9a04c82c1224d1b4efa7fba06623da2896745ce444d35ed77973759e6404b66bb95
Example (SignMultiSignature_simultaneous_adding_private_keys)
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data, _ := transaction.NewSendData().
		SetCoin(1).
		SetValue(transaction.BipToPip(big.NewInt(1))).
		SetTo("Mx1b685a7c1e78726c48f619c497a07ed75fe00483")

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

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

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

}
Output:

0xf901130102010101a0df01941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808002b8e8f8e694db4f4b6942cb927e8d7e3a1f602d0f1fb43b5bd2f8cff8431ca07dd407fa5d2a161581d03cdeb7c94fcd5ade47d376af75f2c92d1483f821fe2ca00d16b6cdbceaadcd0fd72bd39ee17841871da333a571535fccfbcf6285881c2af8431ba07c2d063126024a1e19363e7e254312ca9ab37795b06102da25bd1c0dec81a934a043b7bec83db41c594ac7a8d416fca2f83f0e65ada1221fe659ba4dbe1f3c921af8431ba09318e56a242c39c10ce87ab51d10322cc62cf23885867bc89a24e8c3fa8483e9a04c82c1224d1b4efa7fba06623da2896745ce444d35ed77973759e6404b66bb95
Example (SignSingleSignature_simple)
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(
		transaction.NewSendData().
			SetCoin(1).
			SetValue(transaction.BipToPip(big.NewInt(1))).
			MustSetTo("Mx1b685a7c1e78726c48f619c497a07ed75fe00483"),
	)

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

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

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

	encode, _ := signedTransaction.Encode()
	fmt.Println(encode)

}
Output:

Mx31e61a05adbd13c6b625262704bc305bf7725026
Mtec2166cced36276426360a79934fbf49f29f9e48e9d1f06ef4afc4f557aa3767
0xf8700102010101a0df01941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808001b845f8431ba0fffc3f503ace8a5d0c87efe50cf33ad41e3475459120d9c6fd75bd796b192313a0243d643a799e844ad82382d41cee98137a1d0c5888ff13951919e5e241ab89e0

type BurnTokenData added in v2.2.0

type BurnTokenData struct {
	Coin  CoinID
	Value *big.Int
}

BurnTokenData is a Data of Transaction for decreasing the token's supply. Can be applied to tokens only and is executed from the address of the user who has the necessary amount of this coin. The new supply must be more than or equal to 0.

func NewBurnTokenData added in v2.2.0

func NewBurnTokenData() *BurnTokenData

NewBurnTokenData creates BurnTokenData

func (*BurnTokenData) Encode added in v2.2.0

func (d *BurnTokenData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*BurnTokenData) SetCoin added in v2.2.0

func (d *BurnTokenData) SetCoin(id uint64) *BurnTokenData

func (*BurnTokenData) SetValue added in v2.2.0

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

func (*BurnTokenData) Type added in v2.2.0

func (d *BurnTokenData) Type() Type

Type returns Data type of the transaction.

type BuyCoinData

type BuyCoinData struct {
	CoinToBuy          CoinID   // ID of a coin to get
	ValueToBuy         *big.Int // Amount of CoinToBuy to get
	CoinToSell         CoinID   // ID of a coin to give
	MaximumValueToSell *big.Int // Maximum value of coins to sell
}

BuyCoinData is a Data of Transaction for buy a coin paying another coin (owned by sender).

func NewBuyCoinData

func NewBuyCoinData() *BuyCoinData

NewBuyCoinData returns new data of transaction for buy a coin paying another coin (owned by sender).

Example
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewBuyCoinData().
		SetCoinToBuy(2).
		SetValueToBuy(transaction.BipToPip(big.NewInt(1))).
		SetCoinToSell(1).
		SetMaximumValueToSell(transaction.BipToPip(big.NewInt(1)))

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

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

0xf865010201010495d402880de0b6b3a764000001880de0b6b3a7640000808001b845f8431ca0ad334ececd68741f1f9b96e15a2b5d6a7fe6c378cdaab6c6e8947541e1af74dda038c829477eb261948598fd3dd039aba41aa5691f50d3ee2bb4125bc38b294725

func (*BuyCoinData) Encode

func (d *BuyCoinData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*BuyCoinData) SetCoinToBuy

func (d *BuyCoinData) SetCoinToBuy(id uint64) *BuyCoinData

SetCoinToBuy sets ID of a coin to give.

func (*BuyCoinData) SetCoinToSell

func (d *BuyCoinData) SetCoinToSell(id uint64) *BuyCoinData

SetCoinToSell sets ID of a coin to get.

func (*BuyCoinData) SetMaximumValueToSell

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

SetMaximumValueToSell sets maximum value of coins to sell.

func (*BuyCoinData) SetValueToBuy

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

SetValueToBuy sets amount of CoinToBuy to get.

func (*BuyCoinData) Type

func (d *BuyCoinData) Type() Type

Type returns Data type of the transaction.

type BuySwapPoolData added in v2.2.0

type BuySwapPoolData struct {
	Coins              []CoinID
	ValueToBuy         *big.Int
	MaximumValueToSell *big.Int
}

BuySwapPoolData is a Data of Transaction for buying from the swap pool of the pair.

func NewBuySwapPoolData added in v2.2.0

func NewBuySwapPoolData() *BuySwapPoolData

NewBuySwapPoolData creates BuySwapPoolData

func (*BuySwapPoolData) AddCoin added in v2.2.0

func (d *BuySwapPoolData) AddCoin(ids ...uint64) *BuySwapPoolData

AddCoin sets ID of a coin in exchanging route.

func (*BuySwapPoolData) Encode added in v2.2.0

func (d *BuySwapPoolData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*BuySwapPoolData) SetMaximumValueToSell added in v2.2.0

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

SetMaximumValueToSell sets maximum value of coins to sell.

func (*BuySwapPoolData) SetValueToBuy added in v2.2.0

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

SetValueToBuy sets amount of CoinToBuy to get.

func (*BuySwapPoolData) Type added in v2.2.0

func (d *BuySwapPoolData) Type() Type

Type returns Data type of the transaction.

type ChainID

type ChainID byte

ChainID is network identifier (1 - MainNetChainID, 2 - TestNetChainID)

const (
	MainNetChainID ChainID // 0x01
	TestNetChainID         // 0x02
)

Variants of ChainID

type Check

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

Check is like an ordinary bank check. Each user of network can issue check with any amount of coins and pass it to another person. Receiver will be able to cash a check from arbitrary account.

func NewCheck

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

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

Example
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	check := transaction.NewCheck(
		"480",
		transaction.TestNetChainID,
		999999,
		1,
		transaction.BipToPip(big.NewInt(10)),
		1,
	).SetPassphrase("pass")

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

Mcf89a8334383002830f423f01888ac7230489e8000001b841ea3d022c8326965556f1b651b14d3124947b8683f7b3ab56fca06e0b4204757b2a11dace85d0139ce4e8fdb18369d07905e733683b8229f41bc216c784b4d714011ca017bffff4b3f431dc938239cd2727f0c1dfa61ccdc98727fa8e9baf608b3755f5a05b768c53d09c5e9517487820df439f496e16e459862e7d449360ce69a2ccc4d6

func (*Check) Encode

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

Encode returns string representation of Check. Checks are prefixed with "Mc". RLP-encoded structure in hex format.

func (*Check) EncodeBase64

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

EncodeBase64 returns string representation of Check. RLP-encoded structure in base64 format.

func (*Check) SetPassphrase

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

SetPassphrase sets secret phrase which you will pass to receiver of the check

func (*Check) Sign

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

Sign signs Check with private key

type CheckAddress

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

CheckAddress is hijacking protection

func NewCheckAddress

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

NewCheckAddress sets special passphrase to protect checks from hijacking by another person in the moment of activation

func (*CheckAddress) Proof

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

Proof returns hash of this passphrase is used as private key in ECDSA to prove that sender is the one who owns the check.

Example
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

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

da021d4f84728e0d3d312a18ec84c21768e0caa12a53cb0a1452771f72b0d1a91770ae139fd6c23bcf8cec50f5f2e733eabb8482cf29ee540e56c6639aac469600

type CheckData

type CheckData struct {
	Nonce    []byte   // Unique ID of the check
	ChainID  ChainID  // ID of the network
	DueBlock uint64   // Defines last block height in which the check can be used
	Coin     CoinID   // ID of coin
	Value    *big.Int // Amount of coins
	GasCoin  CoinID   // ID of a coin to pay fee
	Lock     *big.Int // Secret to prevent hijacking
	V        *big.Int // V signature of issuer
	R        *big.Int // R signature of issuer
	S        *big.Int // S signature of issuer
}

CheckData is like an ordinary bank check. Each user of network can issue check with any amount of coins and pass it to another person. Receiver will be able to cash a check from arbitrary account.

func DecodeCheck

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

DecodeCheck returns CheckData from RLP-encoded structure in hex format.

Example
package main

import (
	"encoding/hex"
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data, err := transaction.DecodeCheck("Mcf89a8334383002830f423f01888ac7230489e8000001b841ea3d022c8326965556f1b651b14d3124947b8683f7b3ab56fca06e0b4204757b2a11dace85d0139ce4e8fdb18369d07905e733683b8229f41bc216c784b4d714011ca017bffff4b3f431dc938239cd2727f0c1dfa61ccdc98727fa8e9baf608b3755f5a05b768c53d09c5e9517487820df439f496e16e459862e7d449360ce69a2ccc4d6")
	if err != nil {
		return
	}

	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.MustSender()
	fmt.Println(sender)
	// Result: Mxce931863b9c94a526d94acd8090c1c5955a6eb4b

}
Output:

480
2
1
999999
10000000000000000000
3140622329586495619178957840119431069413669815577585079847850638320450546439777094725740545888163635015645563228183373665216451470665191568503369618620355585
28
17bffff4b3f431dc938239cd2727f0c1dfa61ccdc98727fa8e9baf608b3755f5
5b768c53d09c5e9517487820df439f496e16e459862e7d449360ce69a2ccc4d6
Mxce931863b9c94a526d94acd8090c1c5955a6eb4b

func DecodeCheckBase64

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

DecodeCheckBase64 returns CheckData from RLP-encoded structure in base64 format.

func (*CheckData) MustSender

func (check *CheckData) MustSender() string

MustSender tries to return sender of transaction and panics on error.

func (*CheckData) PublicKey

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

PublicKey returns public key from transaction signature.

func (*CheckData) Sender

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

Sender returns sender of CheckDat from transaction signature.

type CoinID

type CoinID uint32

CoinID ID of a coin.

func (*CoinID) String

func (c *CoinID) String() string

String return CoinID as string.

type CoinSymbol

type CoinSymbol [10]byte

CoinSymbol is symbol of a coin.

func (*CoinSymbol) String

func (s *CoinSymbol) String() string

String returns CoinSymbol as string.

type CreateCoinData

type CreateCoinData struct {
	Name                 string     // Name of a coin
	Symbol               CoinSymbol // 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 uint32     // 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
}

CreateCoinData is a Data of Transaction for creating new coin.

func NewCreateCoinData

func NewCreateCoinData() *CreateCoinData

NewCreateCoinData returns new CreateCoinData of Transaction for creating new coin.

Example
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewCreateCoinData().
		SetName("SUPER TEST").
		SetSymbol("SPRTEST").
		SetInitialAmount(transaction.BipToPip(big.NewInt(100))).
		SetInitialReserve(transaction.BipToPip(big.NewInt(20000))).
		SetConstantReserveRatio(10).
		SetMaxSupply(transaction.BipToPip(big.NewInt(1000)))

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

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

}
Output:

0xf8870102010105b7f68a535550455220544553548a5350525445535400000089056bc75e2d631000008a043c33c19375648000000a893635c9adc5dea00000808001b845f8431ba034615f080a026ee579395aeb4c2eac974a14c091f1bb112629b2b5be0a82628da07f3347c71fa0668d01126dfae49d2b402067275878e4ffd26fd42a73cdf01950

func (*CreateCoinData) Encode

func (d *CreateCoinData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*CreateCoinData) SetConstantReserveRatio

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

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

func (*CreateCoinData) SetInitialAmount

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

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

func (*CreateCoinData) SetInitialReserve

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

SetInitialReserve sets initial reserve in BIP's.

func (*CreateCoinData) SetMaxSupply

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

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

func (*CreateCoinData) SetName

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

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

func (*CreateCoinData) SetSymbol

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

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

func (*CreateCoinData) Type

func (d *CreateCoinData) Type() Type

Type returns Data type of the transaction.

type CreateMultisigData

type CreateMultisigData struct {
	Threshold uint32    // Threshold for the sums of signature weights.
	Weights   []uint32  // Weights of signers
	Addresses []Address // List of signed addresses
}

CreateMultisigData is a Data of Transaction for creating multisig wallet.

func NewCreateMultisigData

func NewCreateMultisigData() *CreateMultisigData

NewCreateMultisigData returns new CreateMultisigData of Transaction for creating multisig wallet.

Example
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

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

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

	signedTx, _ := tx.
		SetNonce(11).
		SetGasPrice(1).
		SetGasCoin(1).
		SetSignatureType(transaction.SignatureTypeSingle).
		Sign("ae089b32e4e0976ca6888cb1023148bd1a9f1cc28c5d442e52e586754ff48d63")

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

}
Output:

0xf8990b0201010cb848f84607c3010305f83f9408d920c5d93dbf23038fe1a54bbb34f41f77677c94772fd5bd06356250e5efe572b6ae615860ee0c17949c7f68ff71b5819c41e8f87cc99bdf6359da3d75808001b845f8431ba0dfc662df298edef48a1a9623a735b55b3acd32023c24a40efc90a85d37209d04a06c2bcd518c2e47ac102941776a68f3ada206260828354e76e2080396bf18f2b1

func (*CreateMultisigData) AddSigData

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

AddSigData sets a set of signers with appropriate weights.

func (*CreateMultisigData) Encode

func (d *CreateMultisigData) Encode() ([]byte, error)

func (*CreateMultisigData) MustAddSigData

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

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

func (*CreateMultisigData) SetThreshold

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

SetThreshold sets threshold for the sums of signature weights.

func (*CreateMultisigData) Type

func (d *CreateMultisigData) Type() Type

Type returns Data type of the transaction.

type CreateSwapPoolData added in v2.2.0

type CreateSwapPoolData struct {
	Coin0   CoinID
	Coin1   CoinID
	Volume0 *big.Int
	Volume1 *big.Int
}

CreateSwapPoolData is a Data of Transaction for creating a liquidity pool for two coins, in volumes specified within this transaction. The volumes will be withdrawn from your balance according to the figure you've specified in the transaction. When a pool is established, a PL-number coin (example: PL-123) is created and issued in the amount equal to the amount of pool liquidity. The calculations related to that liquidity are described below.

func NewCreateSwapPoolData added in v2.2.0

func NewCreateSwapPoolData() *CreateSwapPoolData

NewCreateSwapPoolData returns CreateSwapPoolData transaction

func (*CreateSwapPoolData) Encode added in v2.2.0

func (d *CreateSwapPoolData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*CreateSwapPoolData) SetCoin0 added in v2.2.0

func (d *CreateSwapPoolData) SetCoin0(id uint64) *CreateSwapPoolData

SetCoin0 sets first ID of coin to pair

func (*CreateSwapPoolData) SetCoin1 added in v2.2.0

func (d *CreateSwapPoolData) SetCoin1(id uint64) *CreateSwapPoolData

SetCoin1 sets second ID of coin to pair

func (*CreateSwapPoolData) SetVolume0 added in v2.2.0

func (d *CreateSwapPoolData) SetVolume0(value0 *big.Int) *CreateSwapPoolData

SetVolume0 sets volume to add to reserve of the swap pool of first coin

func (*CreateSwapPoolData) SetVolume1 added in v2.2.0

func (d *CreateSwapPoolData) SetVolume1(value1 *big.Int) *CreateSwapPoolData

SetVolume1 sets volume to add to reserve of the swap pool of second coin

func (*CreateSwapPoolData) Type added in v2.2.0

func (d *CreateSwapPoolData) Type() Type

Type returns Data type of the transaction.

type CreateTokenData added in v2.2.0

type CreateTokenData struct {
	Name          string
	Symbol        CoinSymbol
	InitialAmount *big.Int // Number of tokens to be created at the start
	MaxSupply     *big.Int // Upper limit of the total number of tokens
	Mintable      bool     // Allow new tokens to be issued additionally
	Burnable      bool     // Allow all tokens to be burned
}

CreateTokenData is a Data of Transaction for creation of a token (non-reserve coin).

func NewCreateTokenData added in v2.2.0

func NewCreateTokenData() *CreateTokenData

NewCreateTokenData creates CreateTokenData

func (*CreateTokenData) Encode added in v2.2.0

func (d *CreateTokenData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*CreateTokenData) SetBurnable added in v2.2.0

func (d *CreateTokenData) SetBurnable(burnable bool) *CreateTokenData

func (*CreateTokenData) SetInitialAmount added in v2.2.0

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

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

func (*CreateTokenData) SetMaxSupply added in v2.2.0

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

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

func (*CreateTokenData) SetMintable added in v2.2.0

func (d *CreateTokenData) SetMintable(mintable bool) *CreateTokenData

func (*CreateTokenData) SetName added in v2.2.0

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

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

func (*CreateTokenData) SetSymbol added in v2.2.0

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

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

func (*CreateTokenData) Type added in v2.2.0

func (d *CreateTokenData) Type() Type

Type returns Data type of the transaction.

type Data

type Data interface {
	// Encode returns the byte representation of a transaction Data.
	Encode() ([]byte, error)
	// Type returns Data type of the transaction.
	Type() Type
}

Data is data of transaction

type DeclareCandidacyData

type DeclareCandidacyData struct {
	Address    Address   // Address of candidate
	PubKey     PublicKey // Public key of a validator
	Commission uint32    // Commission (from 0 to 100) from rewards which delegators will pay to validator
	Coin       CoinID    // ID of coin to stake
	Stake      *big.Int  // Amount of coins to stake
}

DeclareCandidacyData is a Data of Transaction for declaring new validator candidacy.

func NewDeclareCandidacyData

func NewDeclareCandidacyData() *DeclareCandidacyData

NewDeclareCandidacyData returns new DeclareCandidacyData of Transaction for declaring new validator candidacy.

Example
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewDeclareCandidacyData().
		MustSetPubKey("Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43").
		SetCommission(10).
		SetCoin(1).
		SetStake(transaction.BipToPip(big.NewInt(5))).
		MustSetAddress("Mx9f7fd953c2c69044b901426831ed03ee0bd0597a")

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

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

0xf8940102010106b843f841949f7fd953c2c69044b901426831ed03ee0bd0597aa00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a430a01884563918244f40000808001b845f8431ba05c5650c040fbce0d4a923a5b0b7fdd4bf52156736a50e7bc1b175a4cbed68c60a07dd76883673bd41fa1293dc38313ec5288dd23c67281f851a67e83fcb917faa7

func (*DeclareCandidacyData) Encode

func (d *DeclareCandidacyData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*DeclareCandidacyData) MustSetAddress

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

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

func (*DeclareCandidacyData) MustSetPubKey

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

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

func (*DeclareCandidacyData) SetAddress

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

SetAddress sets address of candidate. This address would be able to control candidate. Also all rewards will be sent to this address

func (*DeclareCandidacyData) SetCoin

SetCoin sets ID of coin to stake.

func (*DeclareCandidacyData) SetCommission

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

SetCommission sets commission (from 0 to 100) from rewards which delegators will pay to validator.

func (*DeclareCandidacyData) SetPubKey

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

SetPubKey sets public key of a validator.

func (*DeclareCandidacyData) SetStake

func (d *DeclareCandidacyData) SetStake(value *big.Int) *DeclareCandidacyData

SetStake sets amount of coins to stake.

func (*DeclareCandidacyData) Type

func (d *DeclareCandidacyData) Type() Type

Type returns Data type of the transaction.

type DeepLink struct {
	Type     Type    // type of transaction
	Data     []byte  // data of transaction (depends on transaction type)
	Payload  []byte  // optional, arbitrary user-defined bytes
	Nonce    *uint32 `rlp:"nilList"` // optional, used for prevent transaction reply
	GasPrice *uint32 `rlp:"nilList"` // optional, fee multiplier, should be equal or greater than current mempool min gas price
	GasCoin  *CoinID `rlp:"nilList"` // optional, ID of a coin to pay fee, right padded with zeros
	// contains filtered or unexported fields
}
func NewDeepLink(data Data) (*DeepLink, error)
func (d *DeepLink) CreateLink(pass string) (string, error)

Returns url link.

func (*DeepLink) Encode

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

Returns tx-like data. RLP-encoded structure in base64url format.

func (*DeepLink) MustSetUrl added in v2.3.0

func (d *DeepLink) MustSetUrl(value string) *DeepLink

func (*DeepLink) SetGasCoin

func (d *DeepLink) SetGasCoin(id uint64) *DeepLink

SetGasCoin sets ID of a coin to pay fee

func (*DeepLink) SetGasPrice

func (d *DeepLink) SetGasPrice(gasPrice uint32) *DeepLink

SetGasPrice sets fee multiplier.

func (*DeepLink) SetNonce

func (d *DeepLink) SetNonce(nonce uint32) *DeepLink

Set nonce of transaction

func (*DeepLink) SetPayload

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

Set arbitrary user-defined bytes

func (*DeepLink) SetUrl added in v2.3.0

func (d *DeepLink) SetUrl(value string) (*DeepLink, error)

type DelegateData

type DelegateData struct {
	PubKey PublicKey // Public key of a validator
	Coin   CoinID    // ID of coin to stake
	Value  *big.Int  // Amount of coins to stake
}

DelegateData is a Data of Transaction for delegating funds to validator.

func NewDelegateData

func NewDelegateData() *DelegateData

NewDelegateData returns new DelegateData of Transaction for delegating funds to validator

Example
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewDelegateData().
		MustSetPubKey("Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43").
		SetCoin(1).
		SetValue(transaction.BipToPip(big.NewInt(10)))

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

}
Output:

0xf87c0102010107aceba00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a4301888ac7230489e80000808001b845f8431ca016bed99d271578829200f5c7c8f2f04dbf242b1d2c4ed4676c6f3480ade1f6a3a0677cac19e1a36367358cdeeed4a66aa135615b41206f502b9284239539084b5a

func (*DelegateData) Encode

func (d *DelegateData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*DelegateData) MustSetPubKey

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

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

func (*DelegateData) SetCoin

func (d *DelegateData) SetCoin(id uint64) *DelegateData

SetCoin sets ID of coin to stake.

func (*DelegateData) SetPubKey

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

SetPubKey sets public key of a validator.

func (*DelegateData) SetValue

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

SetValue sets amount of coins to stake.

func (*DelegateData) Type

func (d *DelegateData) Type() Type

Type returns Data type of the transaction.

type EditCandidateCommissionData added in v2.2.0

type EditCandidateCommissionData struct {
	PubKey     PublicKey
	Commission uint32
}

func (*EditCandidateCommissionData) Encode added in v2.2.0

func (d *EditCandidateCommissionData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*EditCandidateCommissionData) MustSetPubKey added in v2.4.0

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

func (*EditCandidateCommissionData) SetCommission added in v2.4.0

func (d *EditCandidateCommissionData) SetCommission(commission uint32) *EditCandidateCommissionData

SetCommission sets commission of a validator.

func (*EditCandidateCommissionData) SetPubKey added in v2.4.0

SetPubKey sets public key of a validator.

func (*EditCandidateCommissionData) Type added in v2.2.0

Type returns Data type of the transaction.

type EditCandidateData

type EditCandidateData struct {
	PubKey         PublicKey // Public key of a validator
	RewardAddress  Address   // Address where validator’s rewards go to.
	OwnerAddress   Address   // Address that allows one to start the validator by sending the SetCandidateOnline transaction or stop it by sending the SetCandidateOffline transaction. It also enables the owner to edit the node by sending EditCandidate.
	ControlAddress Address   // Address that allows one to start the validator by sending the SetCandidateOnline transaction or stop it by sending the SetCandidateOffline transaction.
}

EditCandidateData is Data of Transaction for editing existing candidate. This transaction should be sent from OwnerAddress which is set in the "Declare candidacy transaction".

func NewEditCandidateData

func NewEditCandidateData() *EditCandidateData

NewEditCandidateData returns new EditCandidateData of Transaction for editing existing candidate.

Example
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

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

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

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

0xf8b3010201010eb862f860a04ae1ee73e6136c85b0ca933a9a1347758a334885f10b3238398a67ac2eb153b89489e5dc185e6bab772ac8e00cf3fb3f4cb0931c4794e731fcddd37bb6e72286597d22516c8ba3ddffa0941b685a7c1e78726c48f619c497a07ed75fe00483808001b845f8431ca07e6ea59db677f322752f0c62b867b8fd35db69124849c5c6eb037850031f3781a04f14493da1f218205935835b14d9ccca77614d51547a3196a94778ff6f69ee7d

func (*EditCandidateData) Encode

func (d *EditCandidateData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*EditCandidateData) MustSetControlAddress

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

MustSetControlAddress tries to set control address of validator and panics on error.

func (*EditCandidateData) MustSetOwnerAddress

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

MustSetOwnerAddress tries to set owner address of validator and panics on error.

func (*EditCandidateData) MustSetPubKey

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

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

func (*EditCandidateData) MustSetRewardAddress

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

MustSetRewardAddress tries to set reward address of validator and panics on error.

func (*EditCandidateData) SetControlAddress

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

SetControlAddress sets address for managing SetCandidateOnline and SetCandidateOffline data of transaction

func (*EditCandidateData) SetOwnerAddress

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

SetOwnerAddress sets address for managing SetCandidateOnline, SetCandidateOffline and EditCandidate data of transaction

func (*EditCandidateData) SetPubKey

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

SetPubKey sets public key of a validator.

func (*EditCandidateData) SetRewardAddress

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

SetRewardAddress sets address where validator’s rewards go to.

func (*EditCandidateData) Type

func (d *EditCandidateData) Type() Type

Type returns Data type of the transaction.

type EditCandidatePublicKeyData

type EditCandidatePublicKeyData struct {
	PubKey    PublicKey // Public key of a validator
	NewPubKey PublicKey // New public key for change.
}

EditCandidatePublicKeyData is Data of Transaction for editing candidate public key. This transaction should be sent from OwnerAddress which is set in the "Declare candidacy transaction".

func NewEditCandidatePublicKeyData

func NewEditCandidatePublicKeyData() *EditCandidatePublicKeyData

NewEditCandidatePublicKeyData returns new EditCandidatePublicKeyData of Transaction for editing existing candidate.

Example
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewEditCandidatePublicKeyData().
		MustSetPubKey("Mp4ae1ee73e6136c85b0ca933a9a1347758a334885f10b3238398a67ac2eb153b8").
		MustSetNewPubKey("Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43")

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

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

0xf8950102010114b844f842a04ae1ee73e6136c85b0ca933a9a1347758a334885f10b3238398a67ac2eb153b8a00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43808001b845f8431ba0933744d45b17ee431460ce6ce9a707e84f7c43b79bd7eb2067bc35352035e141a07731ab3e52be64a41482409ee3d92f6662e2e6d36ad6789c69fb1d4ec75e766f

func (*EditCandidatePublicKeyData) Encode

func (d *EditCandidatePublicKeyData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*EditCandidatePublicKeyData) MustSetNewPubKey

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

func (*EditCandidatePublicKeyData) MustSetPubKey

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

func (*EditCandidatePublicKeyData) SetNewPubKey

SetNewPubKey sets new public key for change.

func (*EditCandidatePublicKeyData) SetPubKey

SetPubKey sets public key of a validator.

func (*EditCandidatePublicKeyData) Type

func (d *EditCandidatePublicKeyData) Type() Type

Type returns Data type of the transaction.

type EditCoinOwnerData

type EditCoinOwnerData struct {
	Symbol   CoinSymbol
	NewOwner Address
}

EditCoinOwnerData is a Data of Transaction for editing coin owner.

func NewEditCoinOwnerData

func NewEditCoinOwnerData() *EditCoinOwnerData

NewEditCoinOwnerData returns new EditCoinOwnerData of Transaction for editing coin owner.

Example
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewEditCoinOwnerData().
		SetSymbol("SPRTEST").
		MustSetNewOwner("Mx89e5dc185e6bab772ac8e00cf3fb3f4cb0931c47")

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

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

0xf8710102010111a1e08a535052544553540000009489e5dc185e6bab772ac8e00cf3fb3f4cb0931c47808001b845f8431ba03a08817c5b87aaa4eed6ed0c0a86270bbeb0a9f309453ef996546cbee383e8a0a01d34934dba2d1cb07740156d5af8a9e37b68524fd57e4eca1218d12854350f97

func (*EditCoinOwnerData) Encode

func (d *EditCoinOwnerData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*EditCoinOwnerData) MustSetNewOwner

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

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

func (*EditCoinOwnerData) SetNewOwner

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

SetNewOwner sets new owner address of a coin.

func (*EditCoinOwnerData) SetSymbol

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

SetSymbol sets symbol of a coin.

func (*EditCoinOwnerData) Type

func (d *EditCoinOwnerData) Type() Type

Type returns Data type of the transaction.

type EditMultisigData

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

EditMultisigData is a Data of Transaction for editing multisig address.

func NewEditMultisigData

func NewEditMultisigData() *EditMultisigData

NewEditMultisigData returns new EditMultisigData of Transaction for editing multisig address.

Example
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

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

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

	signedTx, _ := tx.
		SetNonce(11).
		SetGasPrice(1).
		SetGasCoin(1).
		SetSignatureType(transaction.SignatureTypeMulti).
		Sign(transaction.MultisigAddress("Mx9c7f68ff71b5819c41e8f87cc99bdf6359da3d75", 21), "ae089b32e4e0976ca6888cb1023148bd1a9f1cc28c5d442e52e586754ff48d63")

	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf8b20b02010112b848f84607c3010305f83f9408d920c5d93dbf23038fe1a54bbb34f41f77677c94772fd5bd06356250e5efe572b6ae615860ee0c17949c7f68ff71b5819c41e8f87cc99bdf6359da3d75808002b85ef85c94f954480762e2cb5cfed7ab85a75e9692b6a138aaf845f8431ca0ebf73833cbf3ff51a9adb013834af1bbd383e3a90ced0bd41a9988f54fd84071a02dad3b6fe991507e59cf8643e1b243c760a6af8f6e6e9264514d3c2b50cc384e

func (*EditMultisigData) AddSigData

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

AddSigData sets a set of signers with appropriate weights.

func (*EditMultisigData) Encode

func (d *EditMultisigData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*EditMultisigData) MustAddSigData

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

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

func (*EditMultisigData) SetThreshold

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

SetThreshold sets threshold for the sums of signature weights.

func (*EditMultisigData) Type

func (d *EditMultisigData) Type() Type

Type returns Data type of the transaction.

type Interface

type Interface interface {

	// SetSignatureType sets signature type.
	SetSignatureType(signatureType SignatureType) Interface
	// SetMultiSignatureType sets signature type to SignatureTypeMulti.
	SetMultiSignatureType() Interface
	// SetNonce sets nonce of transaction.
	SetNonce(nonce uint64) Interface
	// SetGasCoin sets ID of a coin to pay fee.
	SetGasCoin(id uint64) Interface
	// SetGasPrice sets fee multiplier.
	SetGasPrice(price uint8) Interface
	// SetPayload sets arbitrary user-defined bytes.
	SetPayload(payload []byte) Interface
	// SetServiceData sets ServiceData field.
	SetServiceData(serviceData []byte) Interface
	// Sign signs transaction with a private key.
	Sign(key string, prKeys ...string) (Signed, error)
	// Clone returns copy of the transaction.
	Clone() Interface
	// contains filtered or unexported methods
}

Interface is Transaction data installer.

type LockData added in v2.5.0

type LockData struct {
	DueBlock uint64
	Coin     CoinID
	Value    *big.Int
}

LockData is a Data of Transaction for lock coins.

func NewLockData added in v2.5.0

func NewLockData() *LockData

NewLockData returns new LockData of Transaction for lock coins.

func (*LockData) Encode added in v2.5.0

func (d *LockData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*LockData) SetCoin added in v2.5.0

func (d *LockData) SetCoin(id uint64) *LockData

SetCoin sets ID of coin to stake

func (*LockData) SetDueBlock added in v2.5.0

func (d *LockData) SetDueBlock(height uint64) *LockData

SetDueBlock sets ID of coin to stake

func (*LockData) SetValue added in v2.5.0

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

SetValue sets amount of coins to stake

func (*LockData) Type added in v2.5.0

func (d *LockData) Type() Type

Type returns Data type of the transaction.

type LockStakeData added in v2.5.0

type LockStakeData struct {
}

LockStakeData is a Data of Transaction for lock stake.

func NewLockStakeData added in v2.5.0

func NewLockStakeData() *LockStakeData

NewLockStakeData returns new LockStakeData of Transaction for lock stake.

Example
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewLockStakeData()

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

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

0xf851010201012581c0808001b845f8431ca0220af5b0dcd1f4c15fa7dda2e0ecb6e198e28f644a7f516590e4203403f8ea52a00d06d23e4a76f5c1a7581bdab75f6f136bf7df61285e9142aa2c5b7ff10fc3f2

func (*LockStakeData) Encode added in v2.5.0

func (d *LockStakeData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*LockStakeData) Type added in v2.5.0

func (d *LockStakeData) Type() Type

Type returns Data type of the transaction.

type MintTokenData added in v2.2.0

type MintTokenData struct {
	Coin  CoinID
	Value *big.Int
}

MintTokenData is a Data of Transaction for increasing the token's supply. Can be applied to tokens only and is executed from the coin owner address. The new supply must not exceed the MaxSupply value.

func NewMintTokenData added in v2.2.0

func NewMintTokenData() *MintTokenData

NewMintTokenData creates MintTokenData

func (*MintTokenData) Encode added in v2.2.0

func (d *MintTokenData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*MintTokenData) SetCoin added in v2.2.0

func (d *MintTokenData) SetCoin(id uint64) *MintTokenData

func (*MintTokenData) SetValue added in v2.2.0

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

func (*MintTokenData) Type added in v2.2.0

func (d *MintTokenData) Type() Type

Type returns Data type of the transaction.

type MoveStakeData added in v2.2.0

type MoveStakeData struct {
	FromPubKey,
	ToPubKey PublicKey
	Coin  CoinID
	Value *big.Int
}

MoveStakeData is a Data of Transaction for move stake to another candidate.

func NewMoveStakeData added in v2.2.0

func NewMoveStakeData() *MoveStakeData

NewMoveStakeData returns new MoveStakeData of Transaction for move stake to another candidate.

func (*MoveStakeData) Encode added in v2.2.0

func (d *MoveStakeData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*MoveStakeData) MustSetFrom added in v2.2.0

func (d *MoveStakeData) MustSetFrom(key string) *MoveStakeData

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

func (*MoveStakeData) MustSetTo added in v2.2.0

func (d *MoveStakeData) MustSetTo(key string) *MoveStakeData

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

func (*MoveStakeData) SetCoin added in v2.2.0

func (d *MoveStakeData) SetCoin(id uint64) *MoveStakeData

SetCoin sets ID of coin to stake

func (*MoveStakeData) SetFrom added in v2.2.0

func (d *MoveStakeData) SetFrom(key string) (*MoveStakeData, error)

SetFrom sets Public key of current validator

func (*MoveStakeData) SetTo added in v2.2.0

func (d *MoveStakeData) SetTo(key string) (*MoveStakeData, error)

SetTo sets Public key of new validator

func (*MoveStakeData) SetValue added in v2.5.0

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

SetValue sets amount of coins to stake

func (*MoveStakeData) Type added in v2.2.0

func (d *MoveStakeData) Type() Type

Type returns Data type of the transaction.

type MultisendData

type MultisendData struct {
	List []*SendData // List of SendData
}

MultisendData is a Data of Transaction for sending coins to multiple addresses.

func NewMultisendData

func NewMultisendData() *MultisendData

NewMultisendData returns new MultisendData of Transaction for sending coins to multiple addresses.

Example
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewMultisendData().AddItem(
		transaction.NewSendData().
			SetCoin(1).
			SetValue(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18-1), nil))).
			MustSetTo("Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99"),
	).AddItem(
		transaction.NewSendData().
			SetCoin(1).
			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(1).Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf895010201010db844f842f840df0194fe60014a6e9ac91618f5d1cab3fd58cded61ee9988016345785d8a0000df0194ddab6281766ad86497741ff91b6b48fe85012e3c8802c68af0bb140000808001b845f8431ba0718f10b4468989919adabd215f5a6e83bd70eb1358d725541c2661122f66350ba05ab9e5e28107612f89ce56f4d7846edcbf272e8929eaf0c7c945e2530f40b667

func (*MultisendData) AddItem

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

AddItem adds SendData to Multisend list

func (*MultisendData) Encode

func (d *MultisendData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*MultisendData) Type

func (d *MultisendData) Type() Type

Type returns Data type of the transaction.

type PriceVoteData

type PriceVoteData struct {
	Price uint
}

PriceVoteData is a Data of Transaction for

func NewPriceVoteData

func NewPriceVoteData() *PriceVoteData

NewPriceVoteData returns new PriceVoteData of Transaction for

Example
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewPriceVoteData().
		SetPrice(1)

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

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

0xf852010201011382c101808001b845f8431ba00e6ceba5074a56661daf2099872627973e9ee09f82519893a1fda16717b4eec1a00664a550774a27d6f6a56c58d53d39ff46719ddd53423a371339314a65857196

func (*PriceVoteData) Encode

func (d *PriceVoteData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*PriceVoteData) SetPrice

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

SetPrice sets price

func (*PriceVoteData) Type

func (d *PriceVoteData) Type() Type

Type returns Data type of the transaction.

type PublicKey

type PublicKey [32]byte

PublicKey is public key.

func (*PublicKey) String

func (p *PublicKey) String() string

String returns PublicKey as string.

type RecreateCoinData

type RecreateCoinData struct {
	Name                 string     // Name of a coin
	Symbol               CoinSymbol // 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 uint32     // 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

func NewRecreateCoinData() *RecreateCoinData

NewRecreateCoinData returns new RecreateCoinData of Transaction for recreating coin

Example
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewRecreateCoinData().
		SetSymbol("SPRTEST").
		SetInitialAmount(transaction.BipToPip(big.NewInt(100))).
		SetInitialReserve(transaction.BipToPip(big.NewInt(20000))).
		SetConstantReserveRatio(10).
		SetMaxSupply(transaction.BipToPip(big.NewInt(1000)))

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

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

0xf87d0102010110adec808a5350525445535400000089056bc75e2d631000008a043c33c19375648000000a893635c9adc5dea00000808001b845f8431ca04743e4b01fc1c8305bbe9e84f483fb4a7411c419f9ec73124e4e75579a6fd5e0a06d241ed5b6a8c1b9154e7e1cba57de520fc6b5681b2aaa28f578b4e5c071c36b

func (*RecreateCoinData) Encode

func (d *RecreateCoinData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*RecreateCoinData) SetConstantReserveRatio

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

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

func (*RecreateCoinData) SetInitialAmount

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

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

SetInitialReserve sets initial reserve in BIP's.

func (*RecreateCoinData) SetMaxSupply

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

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

func (*RecreateCoinData) SetName

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

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

func (*RecreateCoinData) SetSymbol

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

func (d *RecreateCoinData) Type() Type

Type returns Data type of the transaction.

type RecreateTokenData added in v2.2.0

type RecreateTokenData struct {
	Name          string
	Symbol        CoinSymbol
	InitialAmount *big.Int
	MaxSupply     *big.Int
	Mintable      bool
	Burnable      bool
}

RecreateTokenData is a Data of Transaction for re-creation the coins (both backed and non-reserve).

func NewRecreateTokenData added in v2.2.0

func NewRecreateTokenData() *RecreateTokenData

NewRecreateTokenData creates RecreateTokenData

func (*RecreateTokenData) Encode added in v2.2.0

func (d *RecreateTokenData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*RecreateTokenData) SetBurnable added in v2.2.0

func (d *RecreateTokenData) SetBurnable(burnable bool) *RecreateTokenData

func (*RecreateTokenData) SetInitialAmount added in v2.2.0

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

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

func (*RecreateTokenData) SetMaxSupply added in v2.2.0

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

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

func (*RecreateTokenData) SetMintable added in v2.2.0

func (d *RecreateTokenData) SetMintable(mintable bool) *RecreateTokenData

func (*RecreateTokenData) SetName added in v2.2.0

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

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

func (*RecreateTokenData) SetSymbol added in v2.2.0

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

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

func (*RecreateTokenData) Type added in v2.2.0

func (d *RecreateTokenData) Type() Type

Type returns Data type of the transaction.

type RedeemCheckData

type RedeemCheckData struct {
	RawCheck []byte   // Check received from sender
	Proof    [65]byte // Proof of owning a check: password signed with recipient's address
}

RedeemCheckData is a Data of Transaction for redeeming 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

NewRedeemCheckData returns new RedeemCheckData of Transaction for redeeming a check.

Example
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	check := transaction.NewCheck("02c0c0a4-8023-4654-ac5d-3c39ba1bd19c", transaction.MainNetChainID, 500, 0, big.NewInt(9223372036854775807), 0)
	checkSigned, _ := check.SetPassphrase("secret").Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	checkSignedEncode, _ := checkSigned.Encode()

	pr, _ := transaction.NewCheckAddress("Mx31e61A05adBD13c6B625262704bc305Bf7725026", "secret")
	proof, _ := pr.Proof()

	data := transaction.NewRedeemCheckData().
		MustSetProof(proof).
		MustSetRawCheck(checkSignedEncode)

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

0xf901560102010109b90104f90101b8bcf8baa430326330633061342d383032332d343635342d616335642d336333396261316264313963018201f480887fffffffffffffff80b84164a1ab995f8d8883fa6e7d41e57774f5bcef72aa29cdf61875a4276250f610796d2a50e8dcadfe346fc8d3a555ff97fe3e6f3899879c1d852da6a444609bc1bc001ca0751931e85b03d4ecec72a7b1b2a9b1f92b7a7d260662d9822019cb4b1654f9d0a05e79fdcf59b85fd4637173d6a219255bf8e22898efa12227930c3a761e6225b5b8414aa2806ff70943c8a405011c76a416bf328d642b3ad656ef8cd7d26560facdf22ae4ef789f497bc8bec49b8e56d2bf3c2b2904262858032048d35776a2909e7b00808001b845f8431ca0ceb258c5216b4e95b8bb9121ce97d1133d6003b3de6680af3017e85ee9744c4aa04767cdc002ad8c8d5719c26518e65b222d4f137fc6861d70adba0fbee0bd6688

func (*RedeemCheckData) Encode

func (d *RedeemCheckData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*RedeemCheckData) MustSetProof

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

MustSetProof tries to set proof of owning a check and panics on error.

func (*RedeemCheckData) MustSetRawCheck

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

MustSetRawCheck tries to set check received from sender and panics on error.

func (*RedeemCheckData) SetProof

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

SetProof sets proof of owning a check.

func (*RedeemCheckData) SetRawCheck

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

SetRawCheck sets check received from sender.

func (*RedeemCheckData) Type

func (d *RedeemCheckData) Type() Type

Type returns Data type of the transaction.

type RemoveLimitOrderData added in v2.4.0

type RemoveLimitOrderData struct {
	ID uint64
}

RemoveLimitOrderData is ...

func NewRemoveLimitOrderData added in v2.4.0

func NewRemoveLimitOrderData() *RemoveLimitOrderData

func (*RemoveLimitOrderData) Encode added in v2.4.0

func (d *RemoveLimitOrderData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*RemoveLimitOrderData) SetID added in v2.4.0

SetID sets order ID

func (*RemoveLimitOrderData) Type added in v2.4.0

func (d *RemoveLimitOrderData) Type() Type

Type returns Data type of the transaction.

type RemoveLiquidityData added in v2.2.0

type RemoveLiquidityData struct {
	Coin0          CoinID   // ID of coin to pair
	Coin1          CoinID   // ID of coin to pair
	Liquidity      *big.Int // Volume of shares to be withdrawn from the pool
	MinimumVolume0 *big.Int // Minimum expected volume of coin0 to be returned to the account
	MinimumVolume1 *big.Int // Minimum expected volume of coin1 to be returned to the account
}

RemoveLiquidityData is a Data of Transaction for withdrawing the reserves of a pair from the pool.

func NewRemoveLiquidityData added in v2.2.0

func NewRemoveLiquidityData() *RemoveLiquidityData

NewRemoveLiquidityData returns RemoveLiquidityData

func (*RemoveLiquidityData) Encode added in v2.2.0

func (d *RemoveLiquidityData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*RemoveLiquidityData) SetCoin0 added in v2.2.0

SetCoin0 sets first ID of coin to pair

func (*RemoveLiquidityData) SetCoin1 added in v2.2.0

SetCoin1 sets second ID of coin to pair

func (*RemoveLiquidityData) SetLiquidity added in v2.2.0

func (d *RemoveLiquidityData) SetLiquidity(liquidity *big.Int) *RemoveLiquidityData

SetLiquidity sets volume of shares to be withdrawn from the pool

func (*RemoveLiquidityData) SetMinimumVolume0 added in v2.2.0

func (d *RemoveLiquidityData) SetMinimumVolume0(minimumVolume0 *big.Int) *RemoveLiquidityData

SetMinimumVolume0 sets minimum expected volume of coin0 to be returned to the account

func (*RemoveLiquidityData) SetMinimumVolume1 added in v2.2.0

func (d *RemoveLiquidityData) SetMinimumVolume1(minimumVolume1 *big.Int) *RemoveLiquidityData

SetMinimumVolume1 sets minimum expected volume of coin1 to be returned to the account

func (*RemoveLiquidityData) Type added in v2.2.0

func (d *RemoveLiquidityData) Type() Type

Type returns Data type of the transaction.

type SellAllCoinData

type SellAllCoinData struct {
	CoinToSell        CoinID   // ID of a coin to give
	CoinToBuy         CoinID   // ID of a coin to get
	MinimumValueToBuy *big.Int // Minimum value of coins to get
}

SellAllCoinData is Data of Transaction for selling one coin (owned by sender) in favour of another coin in a system.

func NewSellAllCoinData

func NewSellAllCoinData() *SellAllCoinData

NewSellAllCoinData returns new SellAllCoinData of Transaction for selling one coin (owned by sender) in favour of another coin in a system.

Example
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewSellAllCoinData().
		SetCoinToSell(1).
		SetCoinToBuy(2).
		SetMinimumValueToBuy(transaction.BipToPip(big.NewInt(1)))

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

0xf85c01020101038ccb0102880de0b6b3a7640000808001b845f8431ba0db51e3ca2b75a4a617362946f5f5ee26c75900dae8f8be2400509338bafcd8d4a02e031ead1656d1321520564a34321acc8c6dda63cd4c8bd4530ec641aa4b1c7b

func (*SellAllCoinData) Encode

func (d *SellAllCoinData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*SellAllCoinData) SetCoinToBuy

func (d *SellAllCoinData) SetCoinToBuy(id uint64) *SellAllCoinData

SetCoinToBuy sets ID of a coin to get.

func (*SellAllCoinData) SetCoinToSell

func (d *SellAllCoinData) SetCoinToSell(id uint64) *SellAllCoinData

SetCoinToSell sets ID of a coin to give.

func (*SellAllCoinData) SetMinimumValueToBuy

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

SetMinimumValueToBuy sets minimum value of coins to get

func (*SellAllCoinData) Type

func (d *SellAllCoinData) Type() Type

Type returns Data type of the transaction.

type SellAllSwapPoolData added in v2.2.0

type SellAllSwapPoolData struct {
	Coins             []CoinID // List of coin IDs from given to received.
	MinimumValueToBuy *big.Int // Minimum value of coin to get.
}

SellAllSwapPoolData is a Data of Transaction for selling all existing coins from the swap pool of the pair. Coin to spend (Coins[0]) will be used as GasCoin to pay fee.

func NewSellAllSwapPoolData added in v2.2.0

func NewSellAllSwapPoolData() *SellAllSwapPoolData

NewSellAllSwapPoolData creates SellAllSwapPoolData

func (*SellAllSwapPoolData) AddCoin added in v2.2.0

func (d *SellAllSwapPoolData) AddCoin(ids ...uint64) *SellAllSwapPoolData

AddCoin sets ID of a coin in exchanging route.

func (*SellAllSwapPoolData) Encode added in v2.2.0

func (d *SellAllSwapPoolData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*SellAllSwapPoolData) SetMinimumValueToBuy added in v2.2.0

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

SetMinimumValueToBuy sets minimum value of coins to get

func (*SellAllSwapPoolData) Type added in v2.2.0

func (d *SellAllSwapPoolData) Type() Type

Type returns Data type of the transaction.

type SellCoinData

type SellCoinData struct {
	CoinToSell        CoinID   // ID of a coin to give
	ValueToSell       *big.Int // Amount of CoinToSell to give
	CoinToBuy         CoinID   // ID of a coin to get
	MinimumValueToBuy *big.Int // Minimum value of coins to get
}

SellCoinData is Data of Transaction for selling one coin (owned by sender) in favour of another coin in a system.

func NewSellCoinData

func NewSellCoinData() *SellCoinData

NewSellCoinData returns new SellCoinData of Transaction for selling one coin (owned by sender) in favour of another coin in a system.

Example
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewSellCoinData().
		SetCoinToSell(1).
		SetValueToSell(transaction.BipToPip(big.NewInt(1))).
		SetCoinToBuy(2).
		SetMinimumValueToBuy(transaction.BipToPip(big.NewInt(1)))
	tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(data)
	signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin(1).Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")
	signedTxEncode, _ := signedTx.Encode()
	fmt.Println(signedTxEncode)
}
Output:

0xf865010201010295d401880de0b6b3a764000002880de0b6b3a7640000808001b845f8431ca01552ab0503f8173bef46f2336d48ef6e1fae7bb5aa8b51ec7332b720a8a2f15ca0166970c5d209bac8b5ffae32047f1e4e868c5a20f522aeebb0bc523ae16c64fa

func (*SellCoinData) Encode

func (d *SellCoinData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*SellCoinData) SetCoinToBuy

func (d *SellCoinData) SetCoinToBuy(id uint32) *SellCoinData

SetCoinToBuy sets ID of a coin to get

func (*SellCoinData) SetCoinToSell

func (d *SellCoinData) SetCoinToSell(id uint32) *SellCoinData

SetCoinToSell sets ID of a coin to give

func (*SellCoinData) SetMinimumValueToBuy

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

SetMinimumValueToBuy sets minimum value of coins to get

func (*SellCoinData) SetValueToSell

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

SetValueToSell sets amount of CoinToSell to give

func (*SellCoinData) Type

func (d *SellCoinData) Type() Type

Type returns Data type of the transaction.

type SellSwapPoolData added in v2.2.0

type SellSwapPoolData struct {
	Coins             []CoinID // List of coin IDs from given to received.
	ValueToSell       *big.Int // Amount of coin to spend (first coin in Coins list).
	MinimumValueToBuy *big.Int // Minimum value of coin to get.
}

SellSwapPoolData is a Data of Transaction for selling from the swap pool of the pair.

func NewSellSwapPoolData added in v2.2.0

func NewSellSwapPoolData() *SellSwapPoolData

NewSellSwapPoolData creates SellSwapPoolData

func (*SellSwapPoolData) AddCoin added in v2.2.0

func (d *SellSwapPoolData) AddCoin(ids ...uint64) *SellSwapPoolData

AddCoin sets ID of a coin in exchanging route.

func (*SellSwapPoolData) Encode added in v2.2.0

func (d *SellSwapPoolData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*SellSwapPoolData) SetMinimumValueToBuy added in v2.2.0

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

SetMinimumValueToBuy sets minimum value of coins to get

func (*SellSwapPoolData) SetValueToSell added in v2.2.0

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

SetValueToSell sets amount of CoinToSell to give

func (*SellSwapPoolData) Type added in v2.2.0

func (d *SellSwapPoolData) Type() Type

Type returns Data type of the transaction.

type SendData

type SendData struct {
	Coin  CoinID   // ID of a coin
	To    Address  // Recipient address
	Value *big.Int // Amount of coin to send
}

SendData is a Data of Transaction for sending arbitrary coin.

func NewSendData

func NewSendData() *SendData

NewSendData returns new SendData of Transaction for sending arbitrary coin.

Example
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data, _ := transaction.NewSendData().
		SetCoin(1).
		SetValue(transaction.BipToPip(big.NewInt(1))).
		SetTo("Mx1b685a7c1e78726c48f619c497a07ed75fe00483")

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

0xf8700102010101a0df01941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808001b845f8431ba0fffc3f503ace8a5d0c87efe50cf33ad41e3475459120d9c6fd75bd796b192313a0243d643a799e844ad82382d41cee98137a1d0c5888ff13951919e5e241ab89e0

func (*SendData) Encode

func (d *SendData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*SendData) MustSetTo

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

MustSetTo tries to set recipient address and panics on error

func (*SendData) SetCoin

func (d *SendData) SetCoin(id uint64) *SendData

SetCoin sets ID of a coin.

func (*SendData) SetTo

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

SetTo sets recipient address.

func (*SendData) SetValue

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

SetValue sets amount of coin to send.

func (*SendData) Type

func (d *SendData) Type() Type

Type returns Data type of the transaction.

type SetCandidateOffData

type SetCandidateOffData struct {
	PubKey PublicKey // Public key of a validator
}

SetCandidateOffData is a Data of Transaction for turning candidate off. This transaction should be sent from ControlAddress or OwnerAddress which is set in the "Declare candidacy transaction".

func NewSetCandidateOffData

func NewSetCandidateOffData() *SetCandidateOffData

NewSetCandidateOffData returns new SetCandidateOffData of Transaction for turning candidate off.

Example
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

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

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

0xf872010201010ba2e1a00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43808001b845f8431ca09c65f9b35430a5bcb64dc132f8167abbf878bf29ca2ad146a38a910d7b3dd70fa0706248027a98d2f54e78ab0ab9378b0d134d7e20be04a10c8836b8911c30f41f

func (*SetCandidateOffData) Encode

func (d *SetCandidateOffData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*SetCandidateOffData) MustSetPubKey

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

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

func (*SetCandidateOffData) SetPubKey

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

SetPubKey sets public key of a validator.

func (*SetCandidateOffData) Type

func (d *SetCandidateOffData) Type() Type

Type returns Data type of the transaction.

type SetCandidateOnData

type SetCandidateOnData struct {
	PubKey PublicKey // Public key of a validator
}

SetCandidateOnData is a Data of Transaction for turning candidate on. This transaction should be sent from ControlAddress or OwnerAddress which is set in the "Declare candidacy transaction".

func NewSetCandidateOnData

func NewSetCandidateOnData() *SetCandidateOnData

NewSetCandidateOnData returns new SetCandidateOnData of Transaction for turning candidate on.

Example
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

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

0xf872010201010aa2e1a00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43808001b845f8431ca06be0a4f7103b529bf3bd38a38bde50468b5001fb8c765b49973e0986572e328aa01c11fee8cb064e54a82408199619b9f1dcb35333b47affd8a08a1a6600c5f6d5

func (*SetCandidateOnData) Encode

func (d *SetCandidateOnData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*SetCandidateOnData) MustSetPubKey

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

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

func (*SetCandidateOnData) SetPubKey

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

SetPubKey ets public key of a validator.

func (*SetCandidateOnData) Type

func (d *SetCandidateOnData) Type() Type

Type returns Data type of the transaction.

type SetHaltBlockData

type SetHaltBlockData struct {
	PubKey PublicKey
	Height uint64
}

SetHaltBlockData is a Data of Transaction for voting to stop the network on block. This transaction should be sent from OwnerAddress which is set in the "Declare candidacy transaction".

func NewSetHaltBlockData

func NewSetHaltBlockData() *SetHaltBlockData

NewSetHaltBlockData returns new SetHaltBlockData of Transaction for voting to stop the network on block.

Example
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewSetHaltBlockData().
		MustSetPubKey("Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43").
		SetHeight(123456)

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

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

0xf875010201010fa6e5a00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a438301e240808001b844f8421ca03732a48f4c52c2ec63741ccab959d77c8618b34cbf95f6b8bd1ae57ac87888939fb1551f624c8b7519231716cd6ba9166d14fe27a1e55863ae22f7a3f6d88bfa

func (*SetHaltBlockData) Encode

func (d *SetHaltBlockData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*SetHaltBlockData) MustSetPubKey

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

MustSetPubKey tries to set public key and panics on error.

func (*SetHaltBlockData) SetHeight

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

SetHeight sets height

func (*SetHaltBlockData) SetPubKey

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

SetPubKey sets public key.

func (*SetHaltBlockData) Type

func (d *SetHaltBlockData) Type() Type

Type returns Data type of the transaction.

type Signature

type Signature interface {
	// Encode returns digital signature of transaction.
	Encode() ([]byte, error)
	// Single returns SignatureSingle.
	Single() ([]byte, error)
	// Type returns signature type.
	Type() SignatureType
}

Signature is interface of signatures

type SignatureMulti

type SignatureMulti struct {
	Multisig   Address
	Signatures []*SignatureSingle
}

SignatureMulti is signature of multisig address

func (*SignatureMulti) Encode

func (s *SignatureMulti) Encode() ([]byte, error)

Encode returns digital signature of transaction.

func (*SignatureMulti) Single

func (s *SignatureMulti) Single() ([]byte, error)

Single returns SingleSignature

func (*SignatureMulti) Type

func (s *SignatureMulti) Type() SignatureType

Type returns SignatureType.

type SignatureSingle

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

SignatureSingle is single signature.

func (*SignatureSingle) Encode

func (s *SignatureSingle) Encode() ([]byte, error)

Encode returns digital signature of transaction.

func (*SignatureSingle) Single

func (s *SignatureSingle) Single() ([]byte, error)

Single returns SignatureSingle.

func (*SignatureSingle) Type

func (s *SignatureSingle) Type() SignatureType

Type returns SignatureType of Signature.

type SignatureType

type SignatureType byte

SignatureType is type of signature (1 - SignatureTypeSingle, 2 - SignatureTypeMulti)

const (
	SignatureTypeSingle SignatureType // 0x01
	SignatureTypeMulti                // 0x02
)

Types of Signature

func (SignatureType) String added in v2.1.0

func (i SignatureType) String() string

type Signed

type Signed interface {

	// GetTransaction returns Transaction struct
	GetTransaction() *Transaction
	// Hash returns hash of Transaction.
	Hash() (string, error)
	// Data returns Data of the Transaction.
	Data() Data

	CommissionCoin() CoinID

	// Signature returns Signature interface.
	Signature() (Signature, error)
	// AddSignature adds signature from hex strings.
	AddSignature(signatures ...string) (Signed, error)
	// SignatureData returns bytes of Signature.
	SignatureData() []byte
	// SingleSignatureData returns SignatureData.
	SingleSignatureData() (string, error)
	// SenderAddress returns sender addresses.
	SenderAddress() (string, error)
	// Signers returns set of signers.
	Signers() ([]string, error)
	// Sign signs transaction with a private key.
	Sign(prKey string, prKeys ...string) (Signed, error)
	// Clone returns copy of the transaction.
	Clone() Interface
	// contains filtered or unexported methods
}

Signed is interface of signed Transaction.

func Decode

func Decode(tx string) (Signed, error)

Decode returns Signed model with Transaction and Data.

Example
package main

import (
	"fmt"
	"github.com/MinterTeam/minter-go-sdk/v2/wallet"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	var encode string
	{
		tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(
			transaction.NewSendData().
				SetCoin(1).
				SetValue(transaction.BipToPip(big.NewInt(1))).
				MustSetTo("Mx1b685a7c1e78726c48f619c497a07ed75fe00483"),
		)
		w, _ := wallet.Create("suffer draft bacon typical start retire air sniff large biology mail diagram", "")
		fmt.Println(w.Address)
		signedTransaction, _ := tx.
			SetGasPrice(1).
			SetGasCoin(1).
			SetNonce(1).
			SetPayload([]byte("Hello")).
			Sign(w.PrivateKey)
		encode, _ = signedTransaction.Encode()
	}
	tx, _ := transaction.Decode(encode)

	fmt.Println(tx.Data().Type())
	fmt.Println(tx.Data().(*transaction.SendData).Coin)
	fmt.Println(string(tx.GetTransaction().Payload))
	address, _ := tx.SenderAddress()
	fmt.Println(address)

}
Output:

Mx48f502a9fc324f2c707edc3a2595e72f00c3190c
0x01
1
Hello
Mx48f502a9fc324f2c707edc3a2595e72f00c3190c
Example (SignersOfMultiSignature)
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	decode, _ := transaction.Decode("0xf901130102010101a0df01941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808002b8e8f8e6940023aa9371e0779189ef5a7434456fc21a938945f8cff8431ca07dd407fa5d2a161581d03cdeb7c94fcd5ade47d376af75f2c92d1483f821fe2ca00d16b6cdbceaadcd0fd72bd39ee17841871da333a571535fccfbcf6285881c2af8431ba07c2d063126024a1e19363e7e254312ca9ab37795b06102da25bd1c0dec81a934a043b7bec83db41c594ac7a8d416fca2f83f0e65ada1221fe659ba4dbe1f3c921af8431ba09318e56a242c39c10ce87ab51d10322cc62cf23885867bc89a24e8c3fa8483e9a04c82c1224d1b4efa7fba06623da2896745ce444d35ed77973759e6404b66bb95")
	signers, _ := decode.Signers()
	for _, signer := range signers {
		fmt.Println(signer)
	}

	address, _ := decode.SenderAddress()
	fmt.Println(address)

}
Output:

Mx08d920c5d93dbf23038fe1a54bbb34f41f77677c
Mx6bf192730d01a19739b5030cdb6a60c992712a59
Mx823bb524d5702addbe13086082f7f0310e07d176
Mx0023aa9371e0779189ef5a7434456fc21a938945
Example (SignersOfSingleSignature)
package main

import (
	"fmt"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	decode, _ := transaction.Decode("0xf8700102010101a0df01941b685a7c1e78726c48f619c497a07ed75fe00483880de0b6b3a7640000808001b845f8431ba0fffc3f503ace8a5d0c87efe50cf33ad41e3475459120d9c6fd75bd796b192313a0243d643a799e844ad82382d41cee98137a1d0c5888ff13951919e5e241ab89e0")
	signers, _ := decode.Signers()
	for _, signer := range signers {
		fmt.Println(signer)
	}

	address, _ := decode.SenderAddress()
	fmt.Println(address)

}
Output:

Mx31e61a05adbd13c6b625262704bc305bf7725026
Mx31e61a05adbd13c6b625262704bc305bf7725026

type Transaction

type Transaction struct {
	Nonce         uint64        // used for prevent transaction reply
	ChainID       ChainID       // id of the network (1 - mainnet, 2 - testnet)
	GasPrice      uint8         // fee multiplier, should be equal or greater than current mempool min gas price.
	GasCoin       CoinID        // ID of a coin to pay fee, right padded with zeros
	Type          Type          // type of transaction
	Data          []byte        // data of transaction (depends on transaction type)
	Payload       []byte        // arbitrary user-defined bytes
	ServiceData   []byte        // reserved field
	SignatureType SignatureType // single or multisig transaction
	SignatureData []byte        // digital signature of transaction
}

Transaction is transaction model.

func (*Transaction) Encode

func (tx *Transaction) Encode() (string, error)

Encode returns string representation of a transaction. RLP-encoded structure in hex format.

type Type

type Type byte

Type of transaction is determined by a single byte.

const (
	TypeSend                    Type // 0x01
	TypeSellCoin                     // 0x02
	TypeSellAllCoin                  // 0x03
	TypeBuyCoin                      // 0x04
	TypeCreateCoin                   // 0x05
	TypeDeclareCandidacy             // 0x06
	TypeDelegate                     // 0x07
	TypeUnbond                       // 0x08
	TypeRedeemCheck                  // 0x09
	TypeSetCandidateOnline           // 0x0A
	TypeSetCandidateOffline          // 0x0B
	TypeCreateMultisig               // 0x0C
	TypeMultisend                    // 0x0D
	TypeEditCandidate                // 0x0E
	TypeSetHaltBlock                 // 0x0F
	TypeRecreateCoin                 // 0x10
	TypeEditCoinOwner                // 0x11
	TypeEditMultisig                 // 0x12
	TypePriceVote                    // 0x13
	TypeEditCandidatePublicKey       // 0x14
	TypeAddLiquidity                 // 0x15
	TypeRemoveLiquidity              // 0x16
	TypeSellSwapPool                 // 0x17
	TypeBuySwapPool                  // 0x18
	TypeSellAllSwapPool              // 0x19
	TypeEditCommissionCandidate      // 0x1A
	TypeMoveStake                    // 0x1B
	TypeMintToken                    // 0x1C
	TypeBurnToken                    // 0x1D
	TypeCreateToken                  // 0x1E
	TypeRecreateToken                // 0x1F
	TypeVoteCommission               // 0x20
	TypeVoteUpdate                   // 0x21
	TypeCreateSwapPool               // 0x22
	TypeAddLimitOrder                // 0x23
	TypeRemoveLimitOrder             // 0x24
	TypeLockStake                    // 0x25
	TypeLock                         // 0x26
)

Types of Data

func (Type) String added in v2.1.0

func (t Type) String() string

type UnbondData

type UnbondData struct {
	PubKey PublicKey // Public key of a validator
	Coin   CoinID    // ID of coin to stake
	Value  *big.Int  // Amount of coins to stake
}

UnbondData is a Data of Transaction for unbonding funds from validator's stake.

func NewUnbondData

func NewUnbondData() *UnbondData

NewUnbondData create data of Transaction for unbonding funds from validator's stake

Example
package main

import (
	"fmt"
	"math/big"

	"github.com/MinterTeam/minter-go-sdk/v2/transaction"
)

func main() {
	data := transaction.NewUnbondData().
		MustSetPubKey("Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43").
		SetCoin(1).
		SetValue(transaction.BipToPip(big.NewInt(10)))

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

0xf87c0102010108aceba00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a4301888ac7230489e80000808001b845f8431ca0b51138984781f47bec471a8d6185c5bd57fd6b31dfb323152fe4802084621fc4a040aa80f40f4613f5c4171c36270ab5815e6697f5cbf756250063564233a8456c

func (*UnbondData) Encode

func (d *UnbondData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*UnbondData) MustSetPubKey

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

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

func (*UnbondData) SetCoin

func (d *UnbondData) SetCoin(id uint64) *UnbondData

SetCoin sets ID of coin to stake

func (*UnbondData) SetPubKey

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

SetPubKey sets Public key of a validator

func (*UnbondData) SetValue

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

SetValue sets amount of coins to stake

func (*UnbondData) Type

func (d *UnbondData) Type() Type

Type returns Data type of the transaction.

type VoteCommissionData added in v2.2.0

type VoteCommissionData struct {
	PubKey                  PublicKey
	Height                  uint64
	Coin                    CoinID
	PayloadByte             *big.Int
	Send                    *big.Int
	BuyBancor               *big.Int
	SellBancor              *big.Int
	SellAllBancor           *big.Int
	BuyPool                 *big.Int
	SellPool                *big.Int
	SellAllPool             *big.Int
	CreateTicker3           *big.Int
	CreateTicker4           *big.Int
	CreateTicker5           *big.Int
	CreateTicker6           *big.Int
	CreateTicker7to10       *big.Int
	CreateCoin              *big.Int
	CreateToken             *big.Int
	RecreateCoin            *big.Int
	RecreateToken           *big.Int
	DeclareCandidacy        *big.Int
	Delegate                *big.Int
	Unbond                  *big.Int
	RedeemCheck             *big.Int
	SetCandidateOn          *big.Int
	SetCandidateOff         *big.Int
	CreateMultisig          *big.Int
	MultisendBase           *big.Int
	MultisendDelta          *big.Int
	EditCandidate           *big.Int
	SetHaltBlock            *big.Int
	EditTickerOwner         *big.Int
	EditMultisig            *big.Int
	PriceVote               *big.Int
	EditCandidatePublicKey  *big.Int
	CreateSwapPool          *big.Int
	AddLiquidity            *big.Int
	RemoveLiquidity         *big.Int
	EditCandidateCommission *big.Int
	MoveStake               *big.Int
	MintToken               *big.Int
	BurnToken               *big.Int
	VoteCommission          *big.Int
	VoteUpdate              *big.Int
	More                    []*big.Int `rlp:"tail"`
}

VoteCommissionData is a Data of Transaction for enabling validators to vote for the fees to be changed. The change comes into force once a two-thirds majority is reached. The vote can be sent from the validator owner address.

func NewVoteCommissionData added in v2.2.0

func NewVoteCommissionData() *VoteCommissionData

NewVoteCommissionData creates VoteCommissionData

func (*VoteCommissionData) AddLimitOrderPrice added in v2.4.0

func (d *VoteCommissionData) AddLimitOrderPrice() *big.Int

func (*VoteCommissionData) Encode added in v2.2.0

func (d *VoteCommissionData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*VoteCommissionData) FailedTxPrice added in v2.4.0

func (d *VoteCommissionData) FailedTxPrice() *big.Int

func (*VoteCommissionData) LockPrice added in v2.5.0

func (d *VoteCommissionData) LockPrice() *big.Int

func (*VoteCommissionData) LockStakePrice added in v2.5.0

func (d *VoteCommissionData) LockStakePrice() *big.Int

func (*VoteCommissionData) MoveStakePrice added in v2.5.0

func (d *VoteCommissionData) MoveStakePrice() *big.Int

func (*VoteCommissionData) MustSetPubKey added in v2.2.0

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

MustSetPubKey tries to set public key and panics on error.

func (*VoteCommissionData) RemoveLimitOrderPrice added in v2.4.0

func (d *VoteCommissionData) RemoveLimitOrderPrice() *big.Int

func (*VoteCommissionData) SetCoin added in v2.2.0

SetCoin sets coin for calculate commission price in base coin

func (*VoteCommissionData) SetHeight added in v2.2.0

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

SetHeight sets height

func (*VoteCommissionData) SetPubKey added in v2.2.0

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

SetPubKey sets public key.

func (*VoteCommissionData) Type added in v2.2.0

func (d *VoteCommissionData) Type() Type

Type returns Data type of the transaction.

type VoteUpdateData added in v2.2.0

type VoteUpdateData struct {
	Version string
	PubKey  PublicKey
	Height  uint64
}

VoteUpdateData is a Data of Transaction for

func NewVoteUpdateData added in v2.2.0

func NewVoteUpdateData() *VoteUpdateData

NewVoteUpdateData creates VoteUpdateData

func (*VoteUpdateData) Encode added in v2.2.0

func (d *VoteUpdateData) Encode() ([]byte, error)

Encode returns the byte representation of a transaction Data.

func (*VoteUpdateData) MustSetPubKey added in v2.2.0

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

MustSetPubKey tries to set public key and panics on error.

func (*VoteUpdateData) SetHeight added in v2.2.0

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

SetHeight sets height

func (*VoteUpdateData) SetPubKey added in v2.2.0

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

SetPubKey sets public key.

func (*VoteUpdateData) SetVersion added in v2.2.0

func (d *VoteUpdateData) SetVersion(version string) *VoteUpdateData

SetVersion sets version name.

func (*VoteUpdateData) Type added in v2.2.0

func (d *VoteUpdateData) Type() Type

Type returns Data type of the transaction.

Jump to

Keyboard shortcuts

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