Documentation ¶
Index ¶
- Constants
- Variables
- func AccAddressFromBech32(address string, addressPrefix string) (sdk.AccAddress, error)
- func Bech32FromAccAddress(address []byte, addressPrefix string) (string, error)
- func EncodePublicKeyToAddress(publicKey string, addressPrefix string) (string, error)
- func IsValidAddress(address string, addressPrefix string) bool
- type Account
- func AccountWithPrivateKey(privatekey string, cointype int64, addressPrefix string) (*Account, error)
- func AsCosmosAccount(account base.Account) *Account
- func NewAccountWithMnemonic(mnemonic string, cointype int64, addressPrefix string) (*Account, error)
- func NewCosmosAccountWithMnemonic(mnemonic string) (*Account, error)
- func NewTerraAccountWithMnemonic(mnemonic string) (*Account, error)
- func (a *Account) Address() string
- func (a *Account) PrivateKey() ([]byte, error)
- func (a *Account) PrivateKeyHex() (string, error)
- func (a *Account) PublicKey() []byte
- func (a *Account) PublicKeyHex() string
- func (a *Account) Sign(message []byte, password string) ([]byte, error)
- func (a *Account) SignHex(messageHex string, password string) (*base.OptionalString, error)
- type AccountInfo
- type Chain
- func (c *Chain) AccountOf(address string) (*AccountInfo, error)
- func (c *Chain) BalanceOfAccount(account base.Account) (*base.Balance, error)
- func (c *Chain) BalanceOfAddress(address string) (*base.Balance, error)
- func (c *Chain) BalanceOfAddressAndDenom(address, denom string) (b *base.Balance, err error)
- func (c *Chain) BalanceOfPublicKey(publicKey string) (*base.Balance, error)
- func (c *Chain) BatchFetchTransactionStatus(hashListString string) string
- func (c *Chain) DenomToken(prefix, denom string) *Token
- func (c *Chain) EstimateTransactionFee(transaction base.Transaction) (fee *base.OptionalString, err error)
- func (c *Chain) EstimateTransactionFeeUsePublicKey(transaction base.Transaction, pubkey string) (fee *base.OptionalString, err error)
- func (c *Chain) FetchTransactionDetail(hash string) (detail *base.TransactionDetail, err error)
- func (c *Chain) FetchTransactionStatus(hash string) base.TransactionStatus
- func (c *Chain) GetClient() (*tendermintHttp.HTTP, error)
- func (c *Chain) MainToken() base.Token
- func (c *Chain) SendRawTransaction(signedTx string) (string, error)
- type GradedGasPrice
- type KnownTokenInfo
- type RpcReachability
- type Token
- func (t *Token) BalanceOfAccount(account base.Account) (*base.Balance, error)
- func (t *Token) BalanceOfAddress(address string) (*base.Balance, error)
- func (t *Token) BalanceOfPublicKey(publicKey string) (*base.Balance, error)
- func (t *Token) BuildTransfer(sender, receiver, amount string) (txn base.Transaction, err error)
- func (t *Token) BuildTransferAll(sender, receiver string) (txn base.Transaction, err error)
- func (t *Token) BuildTransferTx(privateKey, receiverAddress, gasPrice, gasLimit, amount, memo string) (string, error)
- func (t *Token) BuildTransferTxWithAccount(account *Account, receiverAddress, gasPrice, gasLimit, amount, memo string) (string, error)
- func (t *Token) CanTransferAll() bool
- func (t *Token) Chain() base.Chain
- func (t *Token) TokenInfo() (*base.TokenInfo, error)
- type Util
Constants ¶
const ( // 0.01 GasPriceLow = "0.01" // 0.025 GasPriceAverage = "0.025" // 0.04 GasPriceHigh = "0.04" // 100000 GasLimitDefault = "100000" // 118 CosmosCointype = 118 // cosmos CosmosPrefix = "cosmos" // uatom CosmosAtomDenom = "uatom" // 330 TerraCointype = 330 // terra TerraPrefix = "terra" // uluna TerraLunaDenom = "uluna" // uusd TerraUSTDenom = "uusd" // 10 TerraGasPrice = "10" // 0.25 TerraGasPriceUST = "0.25" // 80000 TerraGasLimitDefault = "80000" )
Variables ¶
var ( CosmosAtom = &KnownTokenInfo{ Cointype: 118, Prefix: "cosmos", Denom: "uatom", GasPrice: &GradedGasPrice{ Low: "0.01", Average: "0.025", High: "0.04", }, GasLimit: "100000", } TerraLunc = &KnownTokenInfo{ Cointype: 330, Prefix: "terra", Denom: "uluna", GasPrice: &GradedGasPrice{"10", "10", "10"}, GasLimit: "80000", } TerraUst = &KnownTokenInfo{ Cointype: 330, Prefix: "terra", Denom: "uusd", GasPrice: &GradedGasPrice{"0.25", "0.25", "0.25"}, GasLimit: "80000", } )
Functions ¶
func AccAddressFromBech32 ¶
func AccAddressFromBech32(address string, addressPrefix string) (sdk.AccAddress, error)
func Bech32FromAccAddress ¶
func EncodePublicKeyToAddress ¶
@param publicKey can start with 0x or not.
func IsValidAddress ¶
@param chainnet chain name
Types ¶
type Account ¶
type Account struct { Cointype int64 AddressPrefix string // contains filtered or unexported fields }
func AccountWithPrivateKey ¶
func AsCosmosAccount ¶
func NewAccountWithMnemonic ¶
func NewCosmosAccountWithMnemonic ¶
return NewAccountWithMnemonic(mnemonic, 118, "cosmos")
func NewTerraAccountWithMnemonic ¶
return NewAccountWithMnemonic(mnemonic, 330, "terra")
func (*Account) PrivateKeyHex ¶
@return privateKey string that will start with 0x.
func (*Account) PublicKeyHex ¶
The ethereum public key is same as address in coming @return publicKey string that will start with 0x.
type AccountInfo ¶
type Chain ¶
func NewChainWithRpc ¶
func (*Chain) BalanceOfAccount ¶
func (*Chain) BalanceOfAddress ¶
func (*Chain) BalanceOfAddressAndDenom ¶
func (*Chain) BalanceOfPublicKey ¶
Warning: Unable to use public key to query balance
func (*Chain) BatchFetchTransactionStatus ¶
Batch fetch the transaction status, the hash list and the return value, which can only be passed as strings separated by "," @param hashListString The hash of the transactions to be queried in batches, a string concatenated with ",": "hash1,hash2,hash3" @return Batch transaction status, its order is consistent with hashListString: "status1,status2,status3"
func (*Chain) DenomToken ¶
func (*Chain) EstimateTransactionFee ¶
func (c *Chain) EstimateTransactionFee(transaction base.Transaction) (fee *base.OptionalString, err error)
func (*Chain) EstimateTransactionFeeUsePublicKey ¶
func (c *Chain) EstimateTransactionFeeUsePublicKey(transaction base.Transaction, pubkey string) (fee *base.OptionalString, err error)
func (*Chain) FetchTransactionDetail ¶
func (c *Chain) FetchTransactionDetail(hash string) (detail *base.TransactionDetail, err error)
Fetch transaction details through transaction hash
func (*Chain) FetchTransactionStatus ¶
func (c *Chain) FetchTransactionStatus(hash string) base.TransactionStatus
Fetch transaction status through transaction hash
type GradedGasPrice ¶
type KnownTokenInfo ¶
type KnownTokenInfo struct { Cointype int64 Prefix string Denom string GasPrice *GradedGasPrice GasLimit string }
type RpcReachability ¶
type RpcReachability struct { }
func NewRpcReachability ¶
func NewRpcReachability() *RpcReachability
func (*RpcReachability) LatencyOf ¶
func (r *RpcReachability) LatencyOf(rpc string, timeout int64) (l *base.RpcLatency, err error)
@return latency (ms) of rpc query blockNumber. -1 means the connection failed.
type Token ¶
func (*Token) BalanceOfAccount ¶
func (*Token) BalanceOfAddress ¶
func (*Token) BalanceOfPublicKey ¶
Warning: Unable to use public key to query balance
func (*Token) BuildTransfer ¶
func (t *Token) BuildTransfer(sender, receiver, amount string) (txn base.Transaction, err error)
func (*Token) BuildTransferAll ¶
func (t *Token) BuildTransferAll(sender, receiver string) (txn base.Transaction, err error)
func (*Token) BuildTransferTx ¶
func (*Token) BuildTransferTxWithAccount ¶
func (*Token) CanTransferAll ¶
type Util ¶
type Util struct {
AddressPrefix string
}
func NewUtilWithPrefix ¶
func (*Util) DecodeAddressToPublicKey ¶
@throw decode address to public key is not supported
func (*Util) EncodePublicKeyToAddress ¶
@param publicKey can start with 0x or not.