Documentation ¶
Index ¶
- Constants
- func BytesToHex(bz []byte) string
- func GenKey() (string, string, string, error)
- func HexToBytes(str string) []byte
- func RLPHash(x interface{}) (h ethcmn.Hash)
- func ValidAddress(address string) bool
- func ValidPublicKey(publicKey string) bool
- type APIClient
- func (cli *APIClient) BuildEvmTx(senderPubKey, senderPriKey, receiver, value string, load string, ...) (*types.TxEvm, error)
- func (cli *APIClient) CheckTx(hash string) (bool, error)
- func (cli *APIClient) CheckTxWithCtx(ctx context.Context, hash string) (bool, error)
- func (cli *APIClient) DeployTx(mode string, senderPubKey, senderPriKey, value string, load string, ...) (string, string, uint64, error)
- func (cli *APIClient) ERC20BalanceOf(senderPubKey, senderPriKey, contractAddr, address string) (*big.Int, error)
- func (cli *APIClient) ERC20Pay(mode string, senderPubKey, senderPriKey, contractAddr, receiver, value string, ...) (string, uint64, error)
- func (cli *APIClient) Exist(address string) (bool, error)
- func (cli *APIClient) GetAccount(address string) (string, uint64, error)
- func (cli *APIClient) GetBalance(address string) (*big.Int, error)
- func (cli *APIClient) GetContract(address string) (*big.Int, uint64, string, bool, error)
- func (cli *APIClient) GetNonce(address string) uint64
- func (cli *APIClient) InvokeTx(mode string, senderPubKey, senderPriKey, receiver, value string, load string, ...) (string, string, uint64, error)
- func (cli *APIClient) Payment(mode string, senderPubKey, senderPriKey, receiver, value string, ...) (string, error)
- func (cli *APIClient) Payments(mode string, senderPubKey, senderPriKey string, pays []Operation, ...) (string, error)
- func (cli *APIClient) QueryTx(senderPubKey, senderPriKey, receiver, value string, load string, ...) (string, uint64, error)
- func (cli *APIClient) SendEvmTx(mode string, tx *types.TxEvm) error
- func (cli *APIClient) SendMultisigEvmTx(mode string, tx *types.MultisigEvmTx) error
- func (cli *APIClient) V3GetAccountPayments(address string, cursor, limit int64, order string) ([]V3Payment, error)
- func (cli *APIClient) V3GetAccountTransactions(address string, cursor, limit int64, order string) ([]V3Transaction, error)
- func (cli *APIClient) V3GetLedger(height int64) (*V3Ledger, error)
- func (cli *APIClient) V3GetLedgerPayments(height int64, cursor, limit int64, order string) ([]V3Payment, error)
- func (cli *APIClient) V3GetLedgerTransactions(height int64, cursor, limit int64, order string) ([]V3Transaction, error)
- func (cli *APIClient) V3GetLedgers(cursor, limit int64, order string) ([]V3Ledger, error)
- func (cli *APIClient) V3GetPayments(symbol string, cursor, limit int64, order string) ([]V3Payment, error)
- func (cli *APIClient) V3GetTransaction(tx string) (*V3Transaction, error)
- func (cli *APIClient) V3GetTransactions(cursor, limit int64, order string) ([]V3Transaction, error)
- func (cli *APIClient) V3GetTxPayments(tx string, cursor, limit int64, order string) ([]V3Payment, error)
- type MultiSignature
- type Operation
- type PubKeyMultisigThreshold
- type SignedBatchTx
- type SignedEvmTx
- type SignedMultisigEvmTx
- type V3Ledger
- type V3Payment
- type V3Transaction
Constants ¶
const ( MODE_DEFAULT = "commit" MODE_ASYNC = "async" MODE_SYNC = "sync" )
const VERSION = "gosdk-v1.3.0"
Variables ¶
This section is empty.
Functions ¶
func BytesToHex ¶
func HexToBytes ¶
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
func NewAPIClient ¶
NewAPIClient new mondo api client,addr is mondo api http base url,like http://127.0.0.1:8889
func (*APIClient) BuildEvmTx ¶
func (cli *APIClient) BuildEvmTx(senderPubKey, senderPriKey, receiver, value string, load string, gasLimit uint64, gasPrice string, memo string) (*types.TxEvm, error)
BuildEvmTx 生成一个EVM交易
func (*APIClient) CheckTxWithCtx ¶
CheckTxWithCtx 检查交易是否已上链,并处理成功.ctx应待deadline
func (*APIClient) DeployTx ¶
func (cli *APIClient) DeployTx(mode string, senderPubKey, senderPriKey, value string, load string, gasLimit uint64, gasPrice string, memo string) (string, string, uint64, error)
DeployTx 部署合约 返回交易hash,合约地址,gas消耗,错误信息 大多数错误evm错误都是gas不足导致的,排查问题时首先提高gasLimit
func (*APIClient) ERC20BalanceOf ¶
func (cli *APIClient) ERC20BalanceOf(senderPubKey, senderPriKey, contractAddr, address string) (*big.Int, error)
ERC20BalanceOf 查询ERC20代币账户余额 此方法不消耗gas,不上链
func (*APIClient) ERC20Pay ¶
func (cli *APIClient) ERC20Pay(mode string, senderPubKey, senderPriKey, contractAddr, receiver, value string, gasLimit uint64, gasPrice string, memo string) (string, uint64, error)
ERC20Pay ERC20代币转账,返回交易hash、使用的gas数量、错误信息
func (*APIClient) GetAccount ¶
GetAccount 获取账户信息,返回余额、nonce,如果账户未上链,返回余额为0,nonce为0
func (*APIClient) GetBalance ¶
GetBalance 获取账户余额 输入:账户地址或者公钥 输出:如果账户未上链返回余额0,error为nil;如果error不为空表示出错
func (*APIClient) GetContract ¶
GetContract 获取合约 输入:合约地址 输出:余额、nonce、合约字节码、是否已自杀、错误信息;如果合约不存在,返回错误;如果是普通地址,正确返回;
func (*APIClient) InvokeTx ¶
func (cli *APIClient) InvokeTx(mode string, senderPubKey, senderPriKey, receiver, value string, load string, gasLimit uint64, gasPrice string, memo string) (string, string, uint64, error)
InvokeTx 调用合约 返回 交易hash,合约执行返回字节码,gas消耗,错误信息
func (*APIClient) Payment ¶
func (cli *APIClient) Payment(mode string, senderPubKey, senderPriKey, receiver, value string, gasLimit uint64, gasPrice string, memo string) (string, error)
Payment 发送签名交易 mode:交易模式 默认为commit模式:交易上链后返回 async:异步模式,节点成功接收交易后返回 sync:同步模式,节点对基本参数校验完成后返回 senderPubKey:转出方公钥 senderPriKey:转出方私钥 receiver:接收方公钥或地址 value:转账金额(实际金额*1e8) gasLimit:gas限额,普通转账21000 gasPrice:建议值1 返回交易hash和错误信息
func (*APIClient) Payments ¶
func (cli *APIClient) Payments(mode string, senderPubKey, senderPriKey string, pays []Operation, gasLimit uint64, gasPrice string, memo string) (string, error)
Payments 发送批量交易 1vN gasLimit:len(pays)*21000
func (*APIClient) QueryTx ¶
func (cli *APIClient) QueryTx(senderPubKey, senderPriKey, receiver, value string, load string, gasLimit uint64, gasPrice string) (string, uint64, error)
QueryTx 查询合约 用于估算gas消耗或者调用合约的只读方法查数据 只在本节点evm内查询,不形成交易,不上链;在不同的节点查询结果可能不一致(节点高度不一致); 返回 合约执行返回字节码,gas消耗,错误信息
func (*APIClient) SendMultisigEvmTx ¶
func (cli *APIClient) SendMultisigEvmTx(mode string, tx *types.MultisigEvmTx) error
SendMultisigEvmTx 发送多签交易
func (*APIClient) V3GetAccountPayments ¶
func (cli *APIClient) V3GetAccountPayments(address string, cursor, limit int64, order string) ([]V3Payment, error)
V3GetAccountPayments 指定账户查payment,账户可以是地址,也可以是公钥
func (*APIClient) V3GetAccountTransactions ¶
func (cli *APIClient) V3GetAccountTransactions(address string, cursor, limit int64, order string) ([]V3Transaction, error)
V3GetAccountTransactions 指定账户查payment
func (*APIClient) V3GetLedger ¶
V3GetLedger 指定高度查询账本(区块)
func (*APIClient) V3GetLedgerPayments ¶
func (cli *APIClient) V3GetLedgerPayments(height int64, cursor, limit int64, order string) ([]V3Payment, error)
V3GetLedgerPayments 指定高度查账本
func (*APIClient) V3GetLedgerTransactions ¶
func (cli *APIClient) V3GetLedgerTransactions(height int64, cursor, limit int64, order string) ([]V3Transaction, error)
V3GetLedgerTransactions 指定高度查tx
func (*APIClient) V3GetLedgers ¶
V3GetLedgers 查询所有账本(区块)
func (*APIClient) V3GetPayments ¶
func (cli *APIClient) V3GetPayments(symbol string, cursor, limit int64, order string) ([]V3Payment, error)
V3GetPayments 查询所有转账记录 symbol:币种,例如OLO,大写,为空时查询所有币种的转账记录
func (*APIClient) V3GetTransaction ¶
func (cli *APIClient) V3GetTransaction(tx string) (*V3Transaction, error)
V3GetTransaction 指定hash查交易
func (*APIClient) V3GetTransactions ¶
func (cli *APIClient) V3GetTransactions(cursor, limit int64, order string) ([]V3Transaction, error)
V3GetTransactions 查询所有交易
type MultiSignature ¶
type MultiSignature struct { PubKey PubKeyMultisigThreshold `json:"pubKey"` // 多签公钥 Signatures []string `json:"signatures"` // 用户签名列表 }
type PubKeyMultisigThreshold ¶
type SignedBatchTx ¶
type SignedBatchTx struct { Mode int `json:"mode"` // 模式:0-default/commit 1-async 2-sync CreatedAt uint64 `json:"createdAt"` // unix nano GasLimit uint64 `json:"gasLimit"` // GasPrice string `json:"gasPrice"` // Nonce uint64 `json:"nonce"` // Sender string `json:"sender"` // address Ops []Operation `json:"operations"` Memo string `json:"memo"` // 备注 Signature string `json:"signature"` // hex编码 }
批量交易
type SignedEvmTx ¶
type SignedEvmTx struct { Mode int `json:"mode"` // 模式:0-default/commit 1-async 2-sync CreatedAt uint64 `json:"createdAt"` // 时间戳unixNano GasLimit uint64 `json:"gasLimit"` // GasPrice string `json:"gasPrice"` // Nonce uint64 `json:"nonce"` // Sender string `json:"sender"` // pubkey Body struct { To string `json:"to"` // 合约地址 Value string `json:"value"` // Load string `json:"load"` // hex编码 Memo string `json:"memo"` // 备注 } `json:"body"` Signature string `json:"signature"` // hex编码 }
type SignedMultisigEvmTx ¶
type SignedMultisigEvmTx struct { Mode int `json:"mode"` // 交易模式,默认为0;0-同步模式 1-全异步 2-半异步;如果tx执行时间较长、网络不稳定、出块慢,建议使用半异步模式。 Deadline uint64 `json:"deadline"` // 有效截止时间 GasLimit uint64 `json:"gasLimit"` // gas限额 GasPrice string `json:"gasPrice"` // gas价格,最低为1 From string `json:"from"` // 多签账户地址 Nonce uint64 `json:"nonce"` // 多签账户nonce To string `json:"to"` // 交易接受者地址或合约地址 Value string `json:"value"` // 交易金额 Load string `json:"load"` // 合约负载,普通原声币转账时为空 Memo string `json:"memo"` // 备注 Signature MultiSignature `json:"signature"` // 交易签名 }
----合约相关
type V3Ledger ¶
type V3Ledger struct { Id uint64 `db:"id" json:"id"` Height int64 `db:"height" json:"height"` BlockHash string `db:"blockHash" json:"blockHash"` BlockSize int `db:"blockSize" json:"blockSize"` Validator string `db:"validator" json:"validator"` TxCount int64 `db:"txCount" json:"txCount"` GasLimit int64 `db:"gasLimit" json:"gasLimit"` GasUsed int64 `db:"gasUsed" json:"gasUsed"` GasPrice string `db:"gasPrice" json:"gasPrice"` CreatedAt time.Time `db:"createdAt" json:"createdAt"` TotalPrice *big.Int `db:"-" json:"-"` }
type V3Payment ¶
type V3Payment struct { Id uint64 `db:"id" json:"id"` Hash string `db:"hash" json:"hash"` Height int64 `db:"height" json:"height"` Idx int `db:"idx" json:"idx"` Sender string `db:"sender" json:"sender"` Receiver string `db:"receiver" json:"receiver"` Symbol string `db:"symbol" json:"symbol"` Contract string `db:"contract" json:"contract"` Value string `db:"value" json:"value"` CreatedAt time.Time `db:"createdAt" json:"createdAt"` }
type V3Transaction ¶
type V3Transaction struct { Id uint64 `db:"id" json:"id"` Hash string `db:"hash" json:"hash"` Height int64 `db:"height" json:"height"` Typei int `db:"typei" json:"typei"` Types string `db:"types" json:"types"` Sender string `db:"sender" json:"sender"` Nonce int64 `db:"nonce" json:"nonce"` Receiver string `db:"receiver" json:"receiver"` Value string `db:"value" json:"value"` GasLimit int64 `db:"gasLimit" json:"gasLimit"` GasUsed int64 `db:"gasUsed" json:"gasUsed"` GasPrice string `db:"gasPrice" json:"gasPrice"` Memo string `db:"memo" json:"memo"` Payload string `db:"payload" json:"payload"` Events string `db:"events" json:"events"` Codei uint32 `db:"codei" json:"codei"` Codes string `db:"codes" json:"codes"` CreatedAt time.Time `db:"createdAt" json:"createdAt"` }