Documentation ¶
Overview ¶
Package bank is mainly used to transfer coins between accounts,query account balances, and implement interface rpc.Bank
In addition, the available units of tokens in the irita system are defined using [coin-type](https://www.irisnet.org/docs/concepts/coin-type.html).
[More Details](https://www.irisnet.org/docs/features/bank.html)
As a quick start:
Transfer coins to other account
client := test.NewClient() amt := types.NewIntWithDecimal(1, 18) coins := types.NewCoins(types.NewCoin("point", amt)) to := "faa1hp29kuh22vpjjlnctmyml5s75evsnsd8r4x0mm" baseTx := types.BaseTx{ From: "test1", Gas: 20000, Memo: "test", Mode: types.Commit, } result,err := client.Bank.Send(to,coins,baseTx) fmt.Println(result)
Burn some coins from your account
client := test.NewClient() amt := types.NewIntWithDecimal(1, 18) coins := types.NewCoins(types.NewCoin("point", amt)) baseTx := types.BaseTx{ From: "test1", Gas: 20000, Memo: "test", Mode: types.Commit, } result,err := client.Bank.Burn(coins, baseTx) fmt.Println(result)
Set account memo
client := test.NewClient() result,err := client.Bank.SetMemoRegexp("testMemo", baseTx) fmt.Println(result)
Queries account information
client := test.NewClient() result,err := client.Bank.QueryAccount("faa1hp29kuh22vpjjlnctmyml5s75evsnsd8r4x0mm") fmt.Println(result)
Queries the token information
client := test.NewClient() result,err := client.Bank.QueryTokenStats("point") fmt.Println(result)
Index ¶
- Constants
- type Account
- type Bank
- type BaseAccount
- func (acc *BaseAccount) Convert() interface{}
- func (acc *BaseAccount) GetAccountNumber() uint64
- func (acc BaseAccount) GetAddress() sdk.AccAddress
- func (acc *BaseAccount) GetCoins() sdk.Coins
- func (acc BaseAccount) GetPubKey() (pk crypto.PubKey)
- func (acc *BaseAccount) GetSequence() uint64
- func (acc BaseAccount) MarshalJSON() ([]byte, error)
- func (acc *BaseAccount) SetAccountNumber(accNumber uint64) error
- func (acc *BaseAccount) SetAddress(addr sdk.AccAddress) error
- func (acc *BaseAccount) SetCoins(coins sdk.Coins) error
- func (acc *BaseAccount) SetPubKey(pubKey crypto.PubKey) error
- func (acc *BaseAccount) SetSequence(seq uint64) error
- func (acc *BaseAccount) UnmarshalJSON(bz []byte) error
- type EventDataMsgSend
- type EventMsgSendCallback
- type Input
- type MsgBurn
- type MsgMultiSend
- type MsgSend
- type Output
- type Receipt
- type Receipts
Constants ¶
const (
ModuleName = "bank"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account interface { GetAddress() sdk.AccAddress SetAddress(sdk.AccAddress) error // errors if already set. GetPubKey() crypto.PubKey // can return nil. SetPubKey(crypto.PubKey) error GetAccountNumber() uint64 SetAccountNumber(uint64) error GetSequence() uint64 SetSequence(uint64) error GetCoins() sdk.Coins SetCoins(sdk.Coins) error }
Account is an interface used to store coins at a given address within state. It presumes a notion of sequence numbers for replay protection, a notion of account numbers for replay protection for previously pruned accounts, and a pubkey for authentication purposes.
Many complex conditions can be used in the concrete struct which implements Account.
type Bank ¶
type Bank interface { QueryAccount(address string) (sdk.BaseAccount, sdk.Error) Send(to string, amount sdk.DecCoins, baseTx sdk.BaseTx) (sdk.ResultTx, sdk.Error) MultiSend(receipts Receipts, baseTx sdk.BaseTx) ([]sdk.ResultTx, sdk.Error) Burn(amount sdk.DecCoins, baseTx sdk.BaseTx) (sdk.ResultTx, sdk.Error) SubscribeSendTx(from, to string, callback EventMsgSendCallback) sdk.Subscription }
expose bank module api for user
func NewClient ¶
func NewClient(bc sdk.BaseClient) Bank
type BaseAccount ¶
type BaseAccount struct { Address sdk.AccAddress `json:"address"` Coins sdk.Coins `json:"coins"` // will be removed next version PubKey []byte `json:"public_key"` AccountNumber uint64 `json:"account_number"` Sequence uint64 `json:"sequence"` }
func (*BaseAccount) Convert ¶
func (acc *BaseAccount) Convert() interface{}
func (*BaseAccount) GetAccountNumber ¶
func (acc *BaseAccount) GetAccountNumber() uint64
Implements Account
func (BaseAccount) GetAddress ¶
func (acc BaseAccount) GetAddress() sdk.AccAddress
Implements sdk.Account.
func (*BaseAccount) GetCoins ¶
func (acc *BaseAccount) GetCoins() sdk.Coins
GetCoins - Implements sdk.Account.
func (BaseAccount) GetPubKey ¶
func (acc BaseAccount) GetPubKey() (pk crypto.PubKey)
GetPubKey - Implements sdk.Account.
func (*BaseAccount) GetSequence ¶
func (acc *BaseAccount) GetSequence() uint64
Implements sdk.Account.
func (BaseAccount) MarshalJSON ¶
func (acc BaseAccount) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of a BaseAccount.
func (*BaseAccount) SetAccountNumber ¶
func (acc *BaseAccount) SetAccountNumber(accNumber uint64) error
Implements Account
func (*BaseAccount) SetAddress ¶
func (acc *BaseAccount) SetAddress(addr sdk.AccAddress) error
Implements sdk.Account.
func (*BaseAccount) SetCoins ¶
func (acc *BaseAccount) SetCoins(coins sdk.Coins) error
SetCoins - Implements sdk.Account.
func (*BaseAccount) SetPubKey ¶
func (acc *BaseAccount) SetPubKey(pubKey crypto.PubKey) error
SetPubKey - Implements sdk.Account.
func (*BaseAccount) SetSequence ¶
func (acc *BaseAccount) SetSequence(seq uint64) error
Implements sdk.Account.
func (*BaseAccount) UnmarshalJSON ¶
func (acc *BaseAccount) UnmarshalJSON(bz []byte) error
UnmarshalJSON unmarshals raw JSON bytes into a BaseAccount.
type EventDataMsgSend ¶
type EventMsgSendCallback ¶
type EventMsgSendCallback func(EventDataMsgSend)
type Input ¶
type Input struct { Address sdk.AccAddress `json:"address"` Coins sdk.Coins `json:"coins"` }
Transaction Input
func NewInput ¶
func NewInput(addr sdk.AccAddress, coins sdk.Coins) Input
NewInput - create a transaction input, used with MsgSend
func (Input) ValidateBasic ¶
ValidateBasic - validate transaction input
type MsgBurn ¶
type MsgBurn struct { Owner sdk.AccAddress `json:"owner"` Coins sdk.Coins `json:"coins"` }
MsgBurn - high level transaction of the coin module
func NewMsgBurn ¶
func NewMsgBurn(owner sdk.AccAddress, coins sdk.Coins) MsgBurn
NewMsgBurn - construct MsgBurn
type MsgMultiSend ¶
func NewMsgMultiSend ¶
func NewMsgMultiSend(in []Input, out []Output) MsgMultiSend
NewMsgSend - construct arbitrary multi-in, multi-out send msg.
func (MsgMultiSend) GetSigners ¶
func (msg MsgMultiSend) GetSigners() []sdk.AccAddress
Implements Msg.
func (MsgMultiSend) Route ¶
func (msg MsgMultiSend) Route() string
type MsgSend ¶
type MsgSend struct { FromAddress sdk.AccAddress `json:"from_address"` ToAddress sdk.AccAddress `json:"to_address"` Amount sdk.Coins `json:"amount"` }
func NewMsgSend ¶
func NewMsgSend(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) MsgSend
NewMsgSend - construct arbitrary multi-in, multi-out send msg.
func (MsgSend) GetSignBytes ¶
func (MsgSend) GetSigners ¶
func (msg MsgSend) GetSigners() []sdk.AccAddress
func (MsgSend) ValidateBasic ¶
type Output ¶
type Output struct { Address sdk.AccAddress `json:"address"` Coins sdk.Coins `json:"coins"` }
Transaction Output
func NewOutput ¶
func NewOutput(addr sdk.AccAddress, coins sdk.Coins) Output
NewOutput - create a transaction output, used with MsgSend
func (Output) ValidateBasic ¶
ValidateBasic - validate transaction output