Documentation
¶
Index ¶
- Constants
- func BytesToHex(bz []byte) string
- func GenKey() (string, string, string, error)
- func HexToBytes(str string) []byte
- 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) Delegate(publicKey, privateKey, receiverAddress string, opType uint8, opValue string) (string, 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) V3DPosNode(address string) (*BeanValidator, error)
- func (cli *APIClient) V3DPosNodeVoters(address string) (*BeanVots, error)
- func (cli *APIClient) V3DPosNodes() ([]BeanValidator, error)
- func (cli *APIClient) V3DPosPool() (*DPOSPool, error)
- func (cli *APIClient) V3DPosPoolLogs(cursor, limit, height int64, order string) ([]DPOSPoolLog, error)
- func (cli *APIClient) V3DPosRankLogs(cursor, limit, height int64, address string, order string) ([]DPOSRankLog, error)
- func (cli *APIClient) V3DPosTcnLogs(cursor, limit, height int64, address string, order string) ([]DPOSTcnLog, error)
- func (cli *APIClient) V3DPosTinLogs(cursor, limit, height int64, address string, order string) ([]DPOSTinLog, error)
- func (cli *APIClient) V3DPosVoter(address string) (*BeanVoter, 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 BeanValidator
- type BeanVot
- type BeanVoter
- type BeanVots
- type DPOSPool
- type DPOSPoolLog
- type DPOSRankLog
- type DPOSTcnLog
- type DPOSTinLog
- type DelegateTx
- type MultiSignature
- type Operation
- type PubKeyMultisigThreshold
- type RPCClient
- func (cli *RPCClient) GetValidator(ctx context.Context, address string) (*types.BeanValidator, error)
- func (cli *RPCClient) SetGenesis(ctx context.Context, genesisPublicKey, genesisPrivateKey string, ...) (string, error)
- func (cli *RPCClient) SetParam(ctx context.Context, genesisPublicKey, genesisPrivateKey string, key string, ...) (string, error)
- func (cli *RPCClient) SetPower(ctx context.Context, genesisPublicKey, genesisPrivateKey string, ...) (string, error)
- func (cli *RPCClient) SetRunfor(ctx context.Context, genesisPublicKey, genesisPrivateKey string, ...) (string, error)
- 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.2.4"
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) Delegate ¶
func (cli *APIClient) Delegate(publicKey, privateKey, receiverAddress string, opType uint8, opValue string) (string, error)
Delegate 用户抵押赎回操作 opType:1-抵押选举 2-赎回 3-领取收益 receiverAddress:抵押时必填抵押节点地址 opValue:操作金额,抵押时为抵押金额,赎回时不填,领取收益时为领取收益金额 返回hash和错误信息
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) V3DPosNode ¶
func (cli *APIClient) V3DPosNode(address string) (*BeanValidator, error)
func (*APIClient) V3DPosNodeVoters ¶
func (*APIClient) V3DPosNodes ¶
func (cli *APIClient) V3DPosNodes() ([]BeanValidator, error)
func (*APIClient) V3DPosPool ¶
func (*APIClient) V3DPosPoolLogs ¶
func (cli *APIClient) V3DPosPoolLogs(cursor, limit, height int64, order string) ([]DPOSPoolLog, error)
func (*APIClient) V3DPosRankLogs ¶
func (*APIClient) V3DPosTcnLogs ¶
func (*APIClient) V3DPosTinLogs ¶
func (*APIClient) V3DPosVoter ¶
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 BeanValidator ¶
type BeanValidator struct { Address string `json:"address"` // 节点公钥 Nonce uint64 `json:"nonce"` // nonce Power uint64 `json:"power"` // 投票权 Genesis bool `json:"genesis"` // 是否是创世节点 RunFor bool `json:"runFor"` // 参与竞选 Balance string `json:"balance"` // 余额(累积收益) Profit string `json:"-"` // 本轮收益 Mortgaged string `json:"mortgaged"` // 已抵押 ToMortgage string `json:"toMortgage"` // 待抵押 Redeem bool `json:"redeem"` // 待赎回 Voters int `json:"voters"` // 投票人数 Voted string `json:"voted"` // 选民贡献 }
type BeanVoter ¶
type BeanVoter struct { Address string `json:"address"` // 选民地址 Balance string `json:"balance"` // 累积收益余额 Validator string `json:"validator"` // 节点地址 Mortgaged string `json:"mortgaged"` // 已抵押 ToMortgage string `json:"toMortgage"` // 待抵押 Burned string `json:"burned"` // 已燃烧 Redeem bool `json:"redeem"` // 赎回标志 }
type DPOSPoolLog ¶
type DPOSPoolLog struct { Id uint64 `db:"id" json:"id"` // 数据库自增id Height uint64 `db:"height" json:"height"` // 去看高度 Balance string `db:"balance" json:"balance"` // 矿池余额 Mined string `db:"mined" json:"mined"` // 挖矿量 Released string `db:"released" json:"released"` // 实际释放量,实际释放量约等于挖矿量 Total string `db:"total" json:"total"` // 总股权 BlockAt time.Time `db:"blockat" json:"blockAt"` // 区块时间 }
type DPOSRankLog ¶
type DPOSRankLog struct { Id uint64 `db:"id" json:"id"` // 数据库自增id Height uint64 `db:"height" json:"height"` // 区块高度 Address string `db:"address" json:"address"` // 节点地址 Mortgaged string `db:"mortgaged" json:"mortgaged"` // 节点抵押量 Voted string `db:"voted" json:"voted"` // 用户投票量 Voters uint64 `db:"voters" json:"voters"` // 投票用户数 Total string `db:"total" json:"total"` // 总股权 Rank uint32 `db:"rank" json:"rank"` // 排名 BlockAt time.Time `db:"blockat" json:"blockAt"` // 区块时间 }
type DPOSTcnLog ¶
type DPOSTcnLog struct { Id uint64 `db:"id" json:"id"` // 数据库自增id Height uint64 `db:"height" json:"height"` // 区块高度 Address string `db:"address" json:"address"` // 节点地址 Mortgaged string `db:"mortgaged" json:"mortgaged"` // 节点抵押量 Voted string `db:"voted" json:"voted"` // 用户投票量 Voters uint64 `db:"voters" json:"voters"` // 投票用户数 Profit string `db:"profit" json:"profit"` // 收益 BlockAt time.Time `db:"blockat" json:"blockAt"` // 区块时间 }
type DPOSTinLog ¶
type DPOSTinLog struct { Id uint64 `db:"id" json:"id"` // 数据库自增id Height uint64 `db:"height" json:"height"` // 区块高度 Address string `db:"address" json:"address"` // 用户地址 Validator string `db:"validator" json:"validator"` // 用户选举的节点地址 Mortgaged string `db:"mortgaged" json:"mortgaged"` // 用户抵押量 Profit string `db:"profit" json:"profit"` // 收益 BlockAt time.Time `db:"blockat" json:"blockAt"` // 区块时间 }
type DelegateTx ¶
type DelegateTx struct { CreatedAt uint64 `json:"createdAt"` // 时间戳unixNano Sender string `json:"sender"` // pubkey Nonce uint64 `json:"nonce"` // OpType uint8 `json:"opType"` // 1-抵押选举 2-赎回 3-领取收益 OpValue string `json:"opValue"` // Op对应的值 Receiver string `json:"receiver"` // 选举节点地址 Signature string `json:"signature"` // hex编码 }
type MultiSignature ¶
type MultiSignature struct { PubKey PubKeyMultisigThreshold `json:"pubKey"` // 多签公钥 Signatures []string `json:"signatures"` // 用户签名列表 }
type PubKeyMultisigThreshold ¶
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
func NewRPCClient ¶
NewRPCClient new tendermint rpc client,remote is tendermint rpc address,like 127.0.0.1:26657
func (*RPCClient) GetValidator ¶
func (cli *RPCClient) GetValidator(ctx context.Context, address string) (*types.BeanValidator, error)
GetValidator 获取validator详细信息
func (*RPCClient) SetGenesis ¶
func (cli *RPCClient) SetGenesis(ctx context.Context, genesisPublicKey, genesisPrivateKey string, nodeAddress string) (string, error)
SetGenesis 系统维护使用 转移节点的创世权,调用此接口需慎重,一旦忘记接收者私钥将会丢失创世权
func (*RPCClient) SetParam ¶
func (cli *RPCClient) SetParam(ctx context.Context, genesisPublicKey, genesisPrivateKey string, key string, value string) (string, error)
SetParam 系统维护使用
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"` }