Documentation ¶
Index ¶
- Constants
- func DecodeAddressToPublicKey(address string) (string, error)
- func EncodePublicKeyToAddress(publicKey string) (string, error)
- func FaucetFundAccount(address string, amount int64, faucetUrl string) (h *base.OptionalString, err error)
- func IsValidAddress(address string) bool
- type Account
- func (a *Account) Address() string
- func (a *Account) DecodeAddressToPublicKey(address string) (string, error)
- func (a *Account) EncodePublicKeyToAddress(publicKey string) (string, error)
- func (a *Account) IsValidAddress(address string) bool
- 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 Chain
- func (c *Chain) BalanceOfAccount(account base.Account) (*base.Balance, error)
- func (c *Chain) BalanceOfAddress(address 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) EstimateGasPrice() (*base.OptionalString, error)
- func (c *Chain) EstimateMaxGasAmountBCS(publicKey []byte, rawTxn *txbuilder.RawTransaction) (uint64, error)
- func (c *Chain) EstimatePayloadGasFeeBCS(account base.Account, data []byte) (*base.OptionalString, error)
- 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) (*base.TransactionDetail, error)
- func (c *Chain) FetchTransactionStatus(hash string) base.TransactionStatus
- func (c *Chain) GenerateTransaction(senderPublicKey string, payload aptostypes.Payload) (txn *aptostypes.Transaction, err error)
- func (c *Chain) GenerateTransactionJson(senderPublicKey string, payload string) (*base.OptionalString, error)
- func (c *Chain) GetClient() (*aptosclient.RestClient, error)
- func (c *Chain) IsAllowedDirectTransferToken(account string) (*base.OptionalBool, error)
- func (c *Chain) MainToken() base.Token
- func (c *Chain) SendRawTransaction(signedTx string) (hash string, err error)
- func (c *Chain) SendSignedTransaction(signedTxn base.SignedTransaction) (hash *base.OptionalString, err error)
- func (c *Chain) SignAndSendTransaction(account base.Account, hexData string) (*base.OptionalString, error)
- func (c *Chain) SignMessage(account base.Account, payload *SignMessagePayload) (*SignMessageResponse, error)
- func (c *Chain) SignMessageJson(account base.Account, payload string) (*SignMessageResponse, error)
- func (c *Chain) SignTransaction(account base.Account, transaction aptostypes.Transaction) (txn *aptostypes.Transaction, err error)
- func (c *Chain) SignTransactionJson(account base.Account, transaction string) (*base.OptionalString, error)
- func (c *Chain) SubmitTransaction(signedTxn aptostypes.Transaction) (txhash string, err error)
- func (c *Chain) SubmitTransactionJson(signedTxn string) (*base.OptionalString, error)
- func (c *Chain) SubmitTransactionPayloadBCS(account base.Account, data []byte) (string, error)
- type IChain
- type NFTFetcher
- type NFTPayloadBCSBuilder
- func (b *NFTPayloadBCSBuilder) CIDAllowDirectTransferPayload() ([]byte, error)
- func (b *NFTPayloadBCSBuilder) CIDRegister(cid uint64) ([]byte, error)
- func (b *NFTPayloadBCSBuilder) CIDTokenTransferPayload(cid int64, toReceiver string) ([]byte, error)
- func (b *NFTPayloadBCSBuilder) CancelTokenOffer(receiver, creator, collection, name string) ([]byte, error)
- func (b *NFTPayloadBCSBuilder) ClaimTokenFromHash(offerHash string, chain *Chain, receiver string) (res []byte, err error)
- func (b *NFTPayloadBCSBuilder) ClaimTokenTransactionParams(sender, creator, collection, name string) ([]byte, error)
- func (b *NFTPayloadBCSBuilder) OfferTokenTransactionNFT(receiver string, nft *base.NFT) ([]byte, error)
- func (b *NFTPayloadBCSBuilder) OfferTokenTransactionParams(receiver, creator, collection, name string) ([]byte, error)
- func (b *NFTPayloadBCSBuilder) TokenTransferPayload(receiver, creator, collectionName, tokenName string, ...) ([]byte, error)
- type RestReachability
- type SignMessagePayload
- type SignMessageResponse
- type SignedTransaction
- type Token
- func (t *Token) BalanceOfAccount(account base.Account) (*base.Balance, error)
- func (t *Token) BalanceOfAddress(address string) (b *base.Balance, err 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, amount string) (*base.OptionalString, error)deprecated
- func (t *Token) BuildTransferTxWithAccount(account *Account, receiverAddress, amount string) (*base.OptionalString, error)deprecated
- func (t *Token) CanTransferAll() bool
- func (t *Token) Chain() base.Chain
- func (t *Token) EnsureOwnerRegistedToken(owner *Account) (*base.OptionalString, error)
- func (t *Token) EstimateFees(account *Account, receiverAddress, amount string) (f *base.OptionalString, err error)deprecated
- func (t *Token) HasRegisted(ownerAddress string) (b *base.OptionalBool, err error)
- func (t *Token) RegisterTokenForOwner(owner *Account) (s *base.OptionalString, err error)
- func (t *Token) TokenInfo() (*base.TokenInfo, error)
- type Transaction
- type Util
Constants ¶
const ( MaxGasAmount = 20000 GasPrice = 100 TxExpireSec = 600 FaucetUrlDevnet = "https://faucet.devnet.aptoslabs.com" FaucetUrlTestnet = "https://faucet.testnet.aptoslabs.com" )
const ( GraphUrlMainnet = graphql.GraphUrlMainnet GraphUrlTestnet = graphql.GraphUrlTestnet )
const ( AptosName = "APT" AptosSymbol = "APT" AptosDecimal = 0 )
Variables ¶
This section is empty.
Functions ¶
func EncodePublicKeyToAddress ¶
@param publicKey can start with 0x or not.
func FaucetFundAccount ¶
func FaucetFundAccount(address string, amount int64, faucetUrl string) (h *base.OptionalString, err error)
*
- This creates an account if it does not exist and mints the specified amount of
- coins into that account
- @param address Hex-encoded 16 bytes Aptos account address wich mints tokens
- @param amount Amount of tokens to mint
- @param faucetUrl default https://faucet.devnet.aptoslabs.com
- @returns Hashes of submitted transactions, e.g. "hash1,has2,hash3,..."
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
func AccountWithPrivateKey ¶
rename for support android. Android cant support both NewAccountWithMnemonic(string) and NewAccountWithPrivateKey(string)
func AsAptosAccount ¶
func NewAccountWithMnemonic ¶
func (*Account) DecodeAddressToPublicKey ¶
@return publicKey that will start with 0x.
func (*Account) EncodePublicKeyToAddress ¶
@param publicKey can start with 0x or not.
func (*Account) IsValidAddress ¶
func (*Account) PrivateKeyHex ¶
@return privateKey string that will start with 0x.
func (*Account) PublicKeyHex ¶
@return publicKey string that will start with 0x.
type Chain ¶
type Chain struct { RestUrl string // contains filtered or unexported fields }
func NewChainWithRestUrl ¶
func (*Chain) BalanceOfAccount ¶
func (*Chain) BalanceOfAddress ¶
func (*Chain) BalanceOfPublicKey ¶
func (*Chain) BatchFetchTransactionStatus ¶
func (*Chain) EstimateGasPrice ¶
func (c *Chain) EstimateGasPrice() (*base.OptionalString, error)
func (*Chain) EstimateMaxGasAmountBCS ¶
func (*Chain) EstimatePayloadGasFeeBCS ¶
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) (*base.TransactionDetail, error)
Fetch transaction details through transaction hash
func (*Chain) FetchTransactionStatus ¶
func (c *Chain) FetchTransactionStatus(hash string) base.TransactionStatus
func (*Chain) GenerateTransaction ¶
func (c *Chain) GenerateTransaction(senderPublicKey string, payload aptostypes.Payload) (txn *aptostypes.Transaction, err error)
func (*Chain) GenerateTransactionJson ¶
func (*Chain) GetClient ¶
func (c *Chain) GetClient() (*aptosclient.RestClient, error)
func (*Chain) IsAllowedDirectTransferToken ¶
func (c *Chain) IsAllowedDirectTransferToken(account string) (*base.OptionalBool, error)
func (*Chain) SendRawTransaction ¶
Send the raw transaction on-chain @return the hex hash string
func (*Chain) SendSignedTransaction ¶
func (c *Chain) SendSignedTransaction(signedTxn base.SignedTransaction) (hash *base.OptionalString, err error)
func (*Chain) SignAndSendTransaction ¶
func (*Chain) SignMessage ¶
func (c *Chain) SignMessage(account base.Account, payload *SignMessagePayload) (*SignMessageResponse, error)
func (*Chain) SignMessageJson ¶
func (*Chain) SignTransaction ¶
func (c *Chain) SignTransaction(account base.Account, transaction aptostypes.Transaction) (txn *aptostypes.Transaction, err error)
func (*Chain) SignTransactionJson ¶
func (*Chain) SubmitTransaction ¶
func (c *Chain) SubmitTransaction(signedTxn aptostypes.Transaction) (txhash string, err error)
func (*Chain) SubmitTransactionJson ¶
func (c *Chain) SubmitTransactionJson(signedTxn string) (*base.OptionalString, error)
type NFTFetcher ¶
func NewNFTFetcher ¶
func NewNFTFetcher(graphUrl string) *NFTFetcher
Default is `GraphUrlMainnet` if graphUrl is emptry.
func NewNFTFetcherWithChain
deprecated
func NewNFTFetcherWithChain(chain *Chain) *NFTFetcher
Deprecated: use `NewNFTFetcher(graphUrl)`
func (*NFTFetcher) FetchNFTsFilterByCreatorAddr ¶
func (f *NFTFetcher) FetchNFTsFilterByCreatorAddr(owner, creatorAddress string) ([]*base.NFT, error)
func (*NFTFetcher) FetchNFTsJsonString ¶
func (f *NFTFetcher) FetchNFTsJsonString(owner string) (*base.OptionalString, error)
type NFTPayloadBCSBuilder ¶
type NFTPayloadBCSBuilder struct { // The contract provider for the CID module. Default is `0xc73d3c0a171c871e1858414734c7776f0b0cfa567c2af7f0070d1436aab2306b` CIDContract string }
* BCS Payload builder for NFT (include Coming CID)
### Demo example for `CIDTokenTransferPayload` ``` var payload, err = builder.CIDTokenTransferPayload(1234, receiverAddress) var gasPrice, err = chain.EstimateGasPrice() var gasAmount, err := chain.EstimatePayloadGasFeeBCS(account, payload) print("estimate gas fee = %s", gasPrice * gasAmount) var hash, err = chain.SubmitTransactionPayloadBCS(account, payload) print("submited hash = %s", hash) ```
func NewNFTPayloadBCSBuilder ¶
func NewNFTPayloadBCSBuilder(contractAddress string) *NFTPayloadBCSBuilder
func (*NFTPayloadBCSBuilder) CIDAllowDirectTransferPayload ¶
func (b *NFTPayloadBCSBuilder) CIDAllowDirectTransferPayload() ([]byte, error)
func (*NFTPayloadBCSBuilder) CIDRegister ¶
func (b *NFTPayloadBCSBuilder) CIDRegister(cid uint64) ([]byte, error)
func (*NFTPayloadBCSBuilder) CIDTokenTransferPayload ¶
func (b *NFTPayloadBCSBuilder) CIDTokenTransferPayload(cid int64, toReceiver string) ([]byte, error)
func (*NFTPayloadBCSBuilder) CancelTokenOffer ¶
func (b *NFTPayloadBCSBuilder) CancelTokenOffer(receiver, creator, collection, name string) ([]byte, error)
func (*NFTPayloadBCSBuilder) ClaimTokenFromHash ¶
func (b *NFTPayloadBCSBuilder) ClaimTokenFromHash(offerHash string, chain *Chain, receiver string) (res []byte, err error)
* Build payload that claim token, the nft info will be obtaining through offer hash.
- @param offerHash The submitted hash of the transaction that offer the token
- @param chain The chain on which the transaction resides
- @param receiver The token receiver will be check whether it matches the nft offer information.
- @return The claim token payload
func (*NFTPayloadBCSBuilder) ClaimTokenTransactionParams ¶
func (b *NFTPayloadBCSBuilder) ClaimTokenTransactionParams(sender, creator, collection, name string) ([]byte, error)
* Build payload that claim token
- @param sender The transferred token owner
- @param creator The token creator
- @param collection The token's collection name
- @param name The token's name
- @return The claim token payload.
func (*NFTPayloadBCSBuilder) OfferTokenTransactionNFT ¶
func (*NFTPayloadBCSBuilder) OfferTokenTransactionParams ¶
func (b *NFTPayloadBCSBuilder) OfferTokenTransactionParams(receiver, creator, collection, name string) ([]byte, error)
* Build payload that offer token
- @param receiver The token receiver
- @param creator The token creator
- @param collection The token's collection name
- @param name The token's name
- @return The offer token payload.
func (*NFTPayloadBCSBuilder) TokenTransferPayload ¶
func (b *NFTPayloadBCSBuilder) TokenTransferPayload(receiver, creator, collectionName, tokenName string, tokenVersion, amount int64) ([]byte, error)
Note: The `tokenVersion`, `amount` should be uint64, but it is not supported by the SDK generated by gomobile.
type RestReachability ¶
type RestReachability struct { }
func NewRestReachability ¶
func NewRestReachability() *RestReachability
func (*RestReachability) LatencyOf ¶
func (r *RestReachability) LatencyOf(rpc string, timeout int64) (l *base.RpcLatency, err error)
@return latency (ms) of rpc query blockNumber. -1 means the connection failed.
type SignMessagePayload ¶
type SignMessagePayload struct { // Should we include the address of the account in the message Address bool `json:"address,omitempty"` // Should we include the domain of the dApp Application bool `json:"application,omitempty"` // Should we include the current chain id the wallet is connected to ChainId bool `json:"chainId,omitempty"` // The message to be signed and displayed to the user Message string `json:"message"` // A nonce the dApp should generate Nonce int64 `json:"nonce"` }
func (*SignMessagePayload) JsonString ¶
func (j *SignMessagePayload) JsonString() string
type SignMessageResponse ¶
type SignMessageResponse struct { Address string `json:"address,omitempty"` Application string `json:"application,omitempty"` ChainId int64 `json:"chainId,omitempty"` Message string `json:"message"` // The message passed in by the user Nonce int64 `json:"nonce"` Prefix string `json:"prefix"` // Should always be APTOS FullMessage string `json:"fullMessage"` // The message that was generated to sign Signature string `json:"signature"` // The signed full message Bitmap []byte `json:"bitmap,omitempty"` // a 4-byte (32 bits) bit-vector of length N }
func (*SignMessageResponse) JsonString ¶
func (j *SignMessageResponse) JsonString() string
type SignedTransaction ¶
type SignedTransaction struct { RawTxn *txbuilder.RawTransaction SignedBytes []byte }
func AsSignedTransaction ¶
func AsSignedTransaction(txn base.SignedTransaction) *SignedTransaction
func (*SignedTransaction) HexString ¶
func (txn *SignedTransaction) HexString() (res *base.OptionalString, err error)
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
func NewMainToken ¶
func (*Token) BalanceOfAccount ¶
func (*Token) BalanceOfAddress ¶
func (*Token) BalanceOfPublicKey ¶
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
deprecated
func (t *Token) BuildTransferTx(privateKey, receiverAddress, amount string) (*base.OptionalString, error)
Deprecated: use `BuildTransfer()`
func (*Token) BuildTransferTxWithAccount
deprecated
func (*Token) CanTransferAll ¶
func (*Token) EnsureOwnerRegistedToken ¶
func (t *Token) EnsureOwnerRegistedToken(owner *Account) (*base.OptionalString, error)
func (*Token) EstimateFees
deprecated
func (*Token) HasRegisted ¶
func (t *Token) HasRegisted(ownerAddress string) (b *base.OptionalBool, err error)
func (*Token) RegisterTokenForOwner ¶
func (t *Token) RegisterTokenForOwner(owner *Account) (s *base.OptionalString, err error)
@return transaction hash if register token succeed.
type Transaction ¶
type Transaction struct {
RawTxn txbuilder.RawTransaction
}
func (*Transaction) SignWithAccount ¶
func (t *Transaction) SignWithAccount(account base.Account) (signedTx *base.OptionalString, err error)
func (*Transaction) SignedTransactionWithAccount ¶
func (t *Transaction) SignedTransactionWithAccount(account base.Account) (signedTx base.SignedTransaction, err error)
type Util ¶
type Util struct { }
func (*Util) DecodeAddressToPublicKey ¶
Warning: Aptos cannot support decode address to public key
func (*Util) EncodePublicKeyToAddress ¶
@param publicKey can start with 0x or not.