Documentation
¶
Overview ¶
Package aptos is a Go interface into the Aptos blockchain.
The Aptos Go SDK provides a way to read on-chain data, submit transactions, and generally interact with the blockchain.
Quick links:
- Aptos Dev Docs for learning more about Aptos and how to use it.
- Examples are standalone runnable examples of how to use the SDK.
You can create a client and send a transfer transaction with the below example:
// Create a Client
client := NewClient(DevnetConfig)
// Create an account, and fund it
account := NewEd25519Account()
err := client.Fund(account.AccountAddress())
if err != nil {
panic(fmt.Sprintf("Failed to fund account %s %w", account.AccountAddress().ToString(), err))
}
// Send funds to a different address
receiver := &AccountAddress{}
receiver.ParseStringRelaxed("0xcafe")
// Build a transaction to send 1 APT to the receiver
amount := 100_000_000 // 1 APT
transferTransaction, err := APTTransferTransaction(client, account, receiver, amount)
if err != nil {
panic(fmt.Sprintf("Failed to build transaction %w", err))
}
// Submit transaction to the blockchain
submitResponse, err := client.SubmitTransaction(transferTransaction)
if err != nil {
panic(fmt.Sprintf("Failed to submit transaction %w", err))
}
// Wait for transaction to complete
err := client.WaitForTransaction(submitResponse.Hash)
if err != nil {
panic(fmt.Sprintf("Failed to wait for transaction %w", err))
}
Index ¶
- Constants
- Variables
- func BytesToHex(bytes []byte) string
- func ConvertArg(typeArg TypeTag, arg any, generics []TypeTag) ([]byte, error)
- func ConvertToBool(arg any) (bool, error)
- func ConvertToU8(arg any) (uint8, error)
- func ConvertToU16(arg any) (uint16, error)
- func ConvertToU32(arg any) (uint32, error)
- func ConvertToU64(arg any) (uint64, error)
- func ConvertToU128(arg any) (*big.Int, error)
- func ConvertToU256(arg any) (*big.Int, error)
- func ConvertToVector(typeArg TypeTag, arg any, generics []TypeTag) ([]byte, error)
- func ConvertToVectorAddress(arg any) ([]byte, error)
- func ConvertToVectorBool(arg any) ([]byte, error)
- func ConvertToVectorGeneric(typeArg TypeTag, arg any, generics []TypeTag) ([]byte, error)
- func ConvertToVectorReference(typeArg TypeTag, arg any, generics []TypeTag) ([]byte, error)
- func ConvertToVectorU8(arg any) ([]byte, error)
- func ConvertToVectorU16(arg any) ([]byte, error)
- func ConvertToVectorU32(arg any) ([]byte, error)
- func ConvertToVectorU64(arg any) ([]byte, error)
- func ConvertToVectorU128(arg any) ([]byte, error)
- func ConvertToVectorU256(arg any) ([]byte, error)
- func Get[T any](rc *NodeClient, getUrl string) (T, error)
- func ParseHex(hexStr string) ([]byte, error)
- func Post[T any](rc *NodeClient, postUrl string, contentType string, body io.Reader) (T, error)
- func RawTransactionPrehash() []byte
- func RawTransactionWithDataPrehash() []byte
- func Sha3256Hash(bytes [][]byte) []byte
- func StrToBigInt(val string) (*big.Int, error)
- func StrToUint64(s string) (uint64, error)
- func XUSyKzC() error
- type Account
- type AccountAddress
- type AccountInfo
- type AccountResourceInfo
- type AccountResourceRecord
- type AdditionalSigners
- type AddressTag
- type AptosClient
- type AptosFaucetClient
- type AptosIndexerClient
- type AptosRpcClient
- type BoolTag
- type ChainIdOption
- type Client
- func (client *Client) Account(address AccountAddress, ledgerVersion ...uint64) (AccountInfo, error)
- func (client *Client) AccountAPTBalance(address AccountAddress, ledgerVersion ...uint64) (uint64, error)
- func (client *Client) AccountModule(address AccountAddress, moduleName string, ledgerVersion ...uint64) (*api.MoveBytecode, error)
- func (client *Client) AccountResource(address AccountAddress, resourceType string, ledgerVersion ...uint64) (map[string]any, error)
- func (client *Client) AccountResources(address AccountAddress, ledgerVersion ...uint64) ([]AccountResourceInfo, error)
- func (client *Client) AccountResourcesBCS(address AccountAddress, ledgerVersion ...uint64) ([]AccountResourceRecord, error)
- func (client *Client) AccountTransactions(address AccountAddress, start *uint64, limit *uint64) ([]*api.CommittedTransaction, error)
- func (client *Client) BatchSubmitTransaction(signedTxns []*SignedTransaction) (*api.BatchSubmitTransactionResponse, error)
- func (client *Client) BlockByHeight(blockHeight uint64, withTransactions bool) (*api.Block, error)
- func (client *Client) BlockByVersion(ledgerVersion uint64, withTransactions bool) (*api.Block, error)
- func (client *Client) BuildSignAndSubmitTransaction(sender TransactionSigner, payload TransactionPayload, options ...any) (*api.SubmitTransactionResponse, error)
- func (client *Client) BuildSignAndSubmitTransactions(sender TransactionSigner, payloads chan TransactionBuildPayload, ...)
- func (client *Client) BuildSignAndSubmitTransactionsWithSignFunction(sender AccountAddress, payloads chan TransactionBuildPayload, ...)
- func (client *Client) BuildTransaction(sender AccountAddress, payload TransactionPayload, options ...any) (*RawTransaction, error)
- func (client *Client) BuildTransactionMultiAgent(sender AccountAddress, payload TransactionPayload, options ...any) (*RawTransactionWithData, error)
- func (client *Client) BuildTransactions(sender AccountAddress, payloads chan TransactionBuildPayload, ...)
- func (client *Client) EntryFunctionWithArgs(address AccountAddress, moduleName string, functionName string, typeArgs []any, ...) (*EntryFunction, error)
- func (client *Client) EstimateGasPrice() (EstimateGasInfo, error)
- func (client *Client) EventsByHandle(account AccountAddress, eventHandle string, fieldName string, start *uint64, ...) ([]*api.Event, error)
- func (client *Client) FetchNextMultisigAddress(address AccountAddress) (*AccountAddress, error)
- func (client *Client) Fund(address AccountAddress, amount uint64) error
- func (client *Client) GetChainId() (uint8, error)
- func (client *Client) GetCoinBalances(address AccountAddress) ([]CoinBalance, error)
- func (client *Client) GetProcessorStatus(processorName string) (uint64, error)
- func (client *Client) Info() (NodeInfo, error)
- func (client *Client) NodeAPIHealthCheck(durationSecs ...uint64) (api.HealthCheckResponse, error)
- func (client *Client) PollForTransaction(hash string, options ...any) (*api.UserTransaction, error)
- func (client *Client) PollForTransactions(txnHashes []string, options ...any) error
- func (client *Client) QueryIndexer(query any, variables map[string]any, options ...graphql.Option) error
- func (client *Client) RemoveHeader(key string)
- func (client *Client) SetHeader(key string, value string)
- func (client *Client) SetTimeout(timeout time.Duration)
- func (client *Client) SimulateTransaction(rawTxn *RawTransaction, sender TransactionSigner, options ...any) ([]*api.UserTransaction, error)
- func (client *Client) SimulateTransactionMultiAgent(rawTxn *RawTransactionWithData, sender TransactionSigner, options ...any) ([]*api.UserTransaction, error)
- func (client *Client) SubmitTransaction(signedTransaction *SignedTransaction) (*api.SubmitTransactionResponse, error)
- func (client *Client) SubmitTransactions(requests chan TransactionSubmissionRequest, ...)
- func (client *Client) TransactionByHash(txnHash string) (*api.Transaction, error)
- func (client *Client) TransactionByVersion(version uint64) (*api.CommittedTransaction, error)
- func (client *Client) Transactions(start *uint64, limit *uint64) ([]*api.CommittedTransaction, error)
- func (client *Client) View(payload *ViewPayload, ledgerVersion ...uint64) ([]any, error)
- func (client *Client) WaitForTransaction(txnHash string, options ...any) (*api.UserTransaction, error)
- func (client *Client) WaitTransactionByHash(txnHash string) (*api.Transaction, error)
- type CoinBalance
- type ConcResponse
- type Ed25519TransactionAuthenticator
- type EntryFunction
- func CoinBatchTransferPayload(coinType *TypeTag, dests []AccountAddress, amounts []uint64) (*EntryFunction, error)
- func CoinTransferPayload(coinType *TypeTag, dest AccountAddress, amount uint64) (*EntryFunction, error)
- func EntryFunctionFromAbi(abi any, moduleAddress AccountAddress, moduleName string, functionName string, ...) (*EntryFunction, error)
- func FungibleAssetPrimaryStoreTransferPayload(faMetadataAddress *AccountAddress, dest AccountAddress, amount uint64) (*EntryFunction, error)
- func FungibleAssetTransferPayload(faMetadataAddress *AccountAddress, source AccountAddress, dest AccountAddress, ...) (*EntryFunction, error)
- func MultisigAddOwnerPayload(owner AccountAddress) *EntryFunction
- func MultisigApprovePayload(multisigAddress AccountAddress, transactionId uint64) (*EntryFunction, error)
- func MultisigChangeThresholdPayload(numSignaturesRequired uint64) (*EntryFunction, error)
- func MultisigCreateAccountPayload(requiredSigners uint64, additionalAddresses []AccountAddress, ...) (*EntryFunction, error)
- func MultisigCreateTransactionPayload(multisigAddress AccountAddress, payload *MultisigTransactionPayload) (*EntryFunction, error)
- func MultisigCreateTransactionPayloadWithHash(multisigAddress AccountAddress, payload *MultisigTransactionPayload) (*EntryFunction, error)
- func MultisigRejectPayload(multisigAddress AccountAddress, transactionId uint64) (*EntryFunction, error)
- func MultisigRemoveOwnerPayload(owner AccountAddress) *EntryFunction
- type EstimateGasInfo
- type EstimateGasUnitPrice
- type EstimateMaxGasAmount
- type EstimatePrioritizedGasUnitPrice
- type ExpirationSeconds
- type FaucetClient
- type FeePayer
- type FeePayerTransactionAuthenticator
- type FungibleAssetClient
- func (client *FungibleAssetClient) Balance(storeAddress *AccountAddress, ledgerVersion ...uint64) (uint64, error)
- func (client *FungibleAssetClient) Decimals() (uint8, error)
- func (client *FungibleAssetClient) IconUri() (string, error)
- func (client *FungibleAssetClient) IsFrozen(storeAddress *AccountAddress, ledgerVersion ...uint64) (bool, error)
- func (client *FungibleAssetClient) IsUntransferable(storeAddress *AccountAddress, ledgerVersion ...uint64) (bool, error)
- func (client *FungibleAssetClient) Maximum(ledgerVersion ...uint64) (*big.Int, error)
- func (client *FungibleAssetClient) Name() (string, error)
- func (client *FungibleAssetClient) PrimaryBalance(owner *AccountAddress, ledgerVersion ...uint64) (uint64, error)
- func (client *FungibleAssetClient) PrimaryIsFrozen(owner *AccountAddress, ledgerVersion ...uint64) (bool, error)
- func (client *FungibleAssetClient) PrimaryStoreAddress(owner *AccountAddress) (*AccountAddress, error)
- func (client *FungibleAssetClient) PrimaryStoreExists(owner *AccountAddress) (bool, error)
- func (client *FungibleAssetClient) ProjectUri() (string, error)
- func (client *FungibleAssetClient) StoreExists(storeAddress *AccountAddress, ledgerVersion ...uint64) (bool, error)
- func (client *FungibleAssetClient) StoreMetadata(storeAddress *AccountAddress, ledgerVersion ...uint64) (*AccountAddress, error)
- func (client *FungibleAssetClient) Supply(ledgerVersion ...uint64) (*big.Int, error)
- func (client *FungibleAssetClient) Symbol() (string, error)
- func (client *FungibleAssetClient) Transfer(sender TransactionSigner, senderStore AccountAddress, ...) (*SignedTransaction, error)
- func (client *FungibleAssetClient) TransferPrimaryStore(sender TransactionSigner, receiverAddress AccountAddress, amount uint64) (*SignedTransaction, error)
- type GasUnitPrice
- type GenericTag
- type HttpError
- type IndexerClient
- func (ic *IndexerClient) GetCoinBalances(address AccountAddress) ([]CoinBalance, error)
- func (ic *IndexerClient) GetProcessorStatus(processorName string) (uint64, error)
- func (ic *IndexerClient) Query(query any, variables map[string]any, options ...graphql.Option) errordeprecated
- func (ic *IndexerClient) QueryIndexer(query any, variables map[string]any, options ...graphql.Option) error
- func (ic *IndexerClient) WaitOnIndexer(processorName string, requestedVersion uint64) error
- type MaxGasAmount
- type ModuleBundle
- type ModuleId
- type MultiAgentRawTransactionWithData
- type MultiAgentTransactionAuthenticator
- type MultiAgentWithFeePayerRawTransactionWithData
- type MultiEd25519TransactionAuthenticator
- type Multisig
- type MultisigTransactionImpl
- type MultisigTransactionPayload
- type MultisigTransactionPayloadVariant
- type NetworkConfig
- type NodeClient
- func (rc *NodeClient) Account(address AccountAddress, ledgerVersion ...uint64) (AccountInfo, error)
- func (rc *NodeClient) AccountAPTBalance(account AccountAddress, ledgerVersion ...uint64) (uint64, error)
- func (rc *NodeClient) AccountModule(address AccountAddress, moduleName string, ledgerVersion ...uint64) (*api.MoveBytecode, error)
- func (rc *NodeClient) AccountResource(address AccountAddress, resourceType string, ledgerVersion ...uint64) (map[string]any, error)
- func (rc *NodeClient) AccountResources(address AccountAddress, ledgerVersion ...uint64) ([]AccountResourceInfo, error)
- func (rc *NodeClient) AccountResourcesBCS(address AccountAddress, ledgerVersion ...uint64) ([]AccountResourceRecord, error)
- func (rc *NodeClient) AccountTransactions(account AccountAddress, start *uint64, limit *uint64) ([]*api.CommittedTransaction, error)
- func (rc *NodeClient) BatchSubmitTransaction(signedTxns []*SignedTransaction) (*api.BatchSubmitTransactionResponse, error)
- func (rc *NodeClient) BatchSubmitTransactions(requests chan TransactionSubmissionRequest, ...)
- func (rc *NodeClient) BlockByHeight(blockHeight uint64, withTransactions bool) (*api.Block, error)
- func (rc *NodeClient) BlockByVersion(ledgerVersion uint64, withTransactions bool) (*api.Block, error)
- func (rc *NodeClient) BuildSignAndSubmitTransaction(sender TransactionSigner, payload TransactionPayload, options ...any) (*api.SubmitTransactionResponse, error)
- func (rc *NodeClient) BuildSignAndSubmitTransactions(sender TransactionSigner, payloads chan TransactionBuildPayload, ...)
- func (rc *NodeClient) BuildSignAndSubmitTransactionsWithSignFnAndWorkerPool(sender AccountAddress, payloads chan TransactionBuildPayload, ...)
- func (rc *NodeClient) BuildSignAndSubmitTransactionsWithSignFunction(sender AccountAddress, payloads chan TransactionBuildPayload, ...)
- func (rc *NodeClient) BuildTransaction(sender AccountAddress, payload TransactionPayload, options ...any) (*RawTransaction, error)
- func (rc *NodeClient) BuildTransactionMultiAgent(sender AccountAddress, payload TransactionPayload, options ...any) (*RawTransactionWithData, error)
- func (rc *NodeClient) BuildTransactions(sender AccountAddress, payloads chan TransactionBuildPayload, ...)
- func (rc *NodeClient) EntryFunctionWithArgs(moduleAddress AccountAddress, moduleName string, functionName string, ...) (*EntryFunction, error)
- func (rc *NodeClient) EstimateGasPrice() (EstimateGasInfo, error)
- func (rc *NodeClient) EventsByHandle(account AccountAddress, eventHandle string, fieldName string, start *uint64, ...) ([]*api.Event, error)
- func (rc *NodeClient) GetBCS(getUrl string) ([]byte, error)
- func (rc *NodeClient) GetChainId() (uint8, error)
- func (rc *NodeClient) Info() (NodeInfo, error)
- func (rc *NodeClient) NodeAPIHealthCheck(durationSecs ...uint64) (api.HealthCheckResponse, error)
- func (rc *NodeClient) NodeHealthCheck(durationSecs ...uint64) (api.HealthCheckResponse, error)deprecated
- func (rc *NodeClient) PollForTransaction(hash string, options ...any) (*api.UserTransaction, error)
- func (rc *NodeClient) PollForTransactions(txnHashes []string, options ...any) error
- func (rc *NodeClient) RemoveHeader(key string)
- func (rc *NodeClient) SetHeader(key string, value string)
- func (rc *NodeClient) SetTimeout(timeout time.Duration)
- func (rc *NodeClient) SimulateTransaction(rawTxn *RawTransaction, sender TransactionSigner, options ...any) ([]*api.UserTransaction, error)
- func (rc *NodeClient) SimulateTransactionMultiAgent(rawTxn *RawTransactionWithData, sender TransactionSigner, options ...any) ([]*api.UserTransaction, error)
- func (rc *NodeClient) SubmitTransaction(signedTxn *SignedTransaction) (*api.SubmitTransactionResponse, error)
- func (rc *NodeClient) SubmitTransactions(requests chan TransactionSubmissionRequest, ...)
- func (rc *NodeClient) TransactionByHash(txnHash string) (*api.Transaction, error)
- func (rc *NodeClient) TransactionByVersion(version uint64) (*api.CommittedTransaction, error)
- func (rc *NodeClient) Transactions(start *uint64, limit *uint64) ([]*api.CommittedTransaction, error)
- func (rc *NodeClient) View(payload *ViewPayload, ledgerVersion ...uint64) ([]any, error)
- func (rc *NodeClient) WaitForTransaction(txnHash string, options ...any) (*api.UserTransaction, error)
- func (rc *NodeClient) WaitTransactionByHash(txnHash string) (*api.Transaction, error)
- type NodeInfo
- type PollPeriod
- type PollTimeout
- type RawTransaction
- func (txn *RawTransaction) MarshalBCS(ser *bcs.Serializer)
- func (txn *RawTransaction) Sign(signer crypto.Signer) (*crypto.AccountAuthenticator, error)
- func (txn *RawTransaction) SignedTransaction(sender crypto.Signer) (*SignedTransaction, error)
- func (txn *RawTransaction) SignedTransactionWithAuthenticator(auth *crypto.AccountAuthenticator) (*SignedTransaction, error)
- func (txn *RawTransaction) SigningMessage() ([]byte, error)
- func (txn *RawTransaction) UnmarshalBCS(des *bcs.Deserializer)
- type RawTransactionImpl
- type RawTransactionWithData
- func (txn *RawTransactionWithData) MarshalBCS(ser *bcs.Serializer)
- func (txn *RawTransactionWithData) SetFeePayer(feePayer AccountAddress) bool
- func (txn *RawTransactionWithData) Sign(signer crypto.Signer) (*crypto.AccountAuthenticator, error)
- func (txn *RawTransactionWithData) SigningMessage() ([]byte, error)
- func (txn *RawTransactionWithData) ToFeePayerSignedTransaction(sender *crypto.AccountAuthenticator, ...) (*SignedTransaction, bool)
- func (txn *RawTransactionWithData) ToMultiAgentSignedTransaction(sender *crypto.AccountAuthenticator, ...) (*SignedTransaction, bool)
- func (txn *RawTransactionWithData) UnmarshalBCS(des *bcs.Deserializer)
- type RawTransactionWithDataImpl
- type RawTransactionWithDataVariant
- type ReferenceTag
- type Script
- type ScriptArgument
- type ScriptArgumentVariant
- type SequenceNumber
- type SequenceNumberTracker
- type SignedTransaction
- type SignedTransactionVariant
- type SignerTag
- type SingleSenderTransactionAuthenticator
- type StructTag
- type TransactionAuthenticator
- type TransactionAuthenticatorImpl
- type TransactionAuthenticatorVariant
- type TransactionBuildPayload
- type TransactionBuildResponse
- type TransactionPayload
- type TransactionPayloadImpl
- type TransactionPayloadVariant
- type TransactionSigner
- type TransactionSubmissionRequest
- type TransactionSubmissionResponse
- type TransactionSubmissionType
- type TypeTag
- type TypeTagImpl
- type TypeTagVariant
- type U8Tag
- type U16Tag
- type U32Tag
- type U64Tag
- type U128Tag
- type U256Tag
- type VectorTag
- type ViewPayload
- type WorkerPoolConfig
Constants ¶
const ( DefaultMaxGasAmount = uint64(100_000) // Default to 0.001 APT max gas amount DefaultGasUnitPrice = uint64(100) // Default to min gas price DefaultExpirationSeconds = uint64(300) // Default to 5 minutes )
const ClientHeader = "X-Aptos-Client"
ClientHeader is the header key for the SDK version
const ContentTypeAptosSignedTxnBcs = "application/x.aptos.signed_transaction+bcs"
ContentTypeAptosSignedTxnBcs header for sending BCS transaction payloads
const ContentTypeAptosViewFunctionBcs = "application/x.aptos.view_function+bcs"
ContentTypeAptosViewFunctionBcs header for sending BCS view function payloads
const HttpErrSummaryLength = 1000
HttpErrSummaryLength is the maximum length of the body to include in the error message
Variables ¶
var AccountFour = types.AccountFour
AccountFour represents the 0x4 address
var AccountOne = types.AccountOne
AccountOne represents the 0x1 address
var AccountThree = types.AccountThree
AccountThree represents the 0x3 address
var AccountTwo = types.AccountTwo
AccountTwo represents the 0x2 address
var AccountZero = types.AccountZero
AccountZero represents the 0x0 address
var AptosCoinTypeTag = TypeTag{&StructTag{ Address: AccountOne, Module: "aptos_coin", Name: "AptosCoin", }}
AptosCoinTypeTag is the TypeTag for 0x1::aptos_coin::AptosCoin
var ClientHeaderValue = "aptos-go-sdk/unk"
ClientHeaderValue is the header value for the SDK version
var DevnetConfig = NetworkConfig{
Name: "devnet",
NodeUrl: "https://api.devnet.aptoslabs.com/v1",
IndexerUrl: "https://api.devnet.aptoslabs.com/v1/graphql",
FaucetUrl: "https://faucet.devnet.aptoslabs.com/",
}
DevnetConfig is for use with devnet. Note devnet resets at least weekly. ChainId differs after each reset.
var LocalnetConfig = NetworkConfig{
Name: "localnet",
ChainId: 4,
NodeUrl: "http://127.0.0.1:8080/v1",
IndexerUrl: "http://127.0.0.1:8090/v1/graphql",
FaucetUrl: "http://127.0.0.1:8081",
}
LocalnetConfig is for use with a localnet, created by the [Aptos CLI](https://aptos.dev/tools/aptos-cli)
To start a localnet, install the Aptos CLI then run:
aptos node run-localnet --with-indexer-api
var MainnetConfig = NetworkConfig{
Name: "mainnet",
ChainId: 1,
NodeUrl: "https://api.mainnet.aptoslabs.com/v1",
IndexerUrl: "https://api.mainnet.aptoslabs.com/v1/graphql",
FaucetUrl: "",
}
MainnetConfig is for use with mainnet. There is no faucet for Mainnet, as these are real user assets.
var NamedNetworks map[string]NetworkConfig
NamedNetworks Map from network name to NetworkConfig
var TestnetConfig = NetworkConfig{
Name: "testnet",
ChainId: 2,
NodeUrl: "https://api.testnet.aptoslabs.com/v1",
IndexerUrl: "https://api.testnet.aptoslabs.com/v1/graphql",
FaucetUrl: "https://faucet.testnet.aptoslabs.com/",
}
TestnetConfig is for use with testnet. Testnet does not reset.
var TransactionPrefix *[]byte
TransactionPrefix is a cached hash prefix for taking transaction hashes
Functions ¶
func BytesToHex ¶
BytesToHex converts bytes to a 0x prefixed hex string
func ConvertToBool ¶
func ConvertToU8 ¶
func ConvertToU16 ¶
func ConvertToU32 ¶
func ConvertToU64 ¶
func ConvertToVector ¶
func ConvertToVectorAddress ¶
ConvertToVectorAddress returns the BCS encoded version of the address vector
func ConvertToVectorBool ¶
ConvertToVectorBool returns the BCS encoded version of the boolean vector
func ConvertToVectorGeneric ¶
ConvertToVectorGeneric returns the BCS encoded version of the generic vector
func ConvertToVectorReference ¶
ConvertToVectorReference returns the BCS encoded version of the reference vector
func ConvertToVectorU8 ¶
ConvertToVectorU8 returns the BCS encoded version of the bytes
func ConvertToVectorU16 ¶
ConvertToVectorU16 returns the BCS encoded version of the bytes
func ConvertToVectorU32 ¶
ConvertToVectorU32 returns the BCS encoded version of the bytes
func ConvertToVectorU64 ¶
ConvertToVectorU64 returns the BCS encoded version of the bytes
func ConvertToVectorU128 ¶
ConvertToVectorU128 returns the BCS encoded version of the bytes
func ConvertToVectorU256 ¶
ConvertToVectorU256 returns the BCS encoded version of the bytes
func Get ¶
func Get[T any](rc *NodeClient, getUrl string) (T, error)
Get makes a GET request to the endpoint and parses the response into the given type with JSON
func Post ¶
Post makes a POST request to the endpoint with the given body and parses the response into the given type with JSON
func RawTransactionPrehash ¶
func RawTransactionPrehash() []byte
RawTransactionPrehash Return the sha3-256 prehash for RawTransaction Do not write to the []byte returned
func RawTransactionWithDataPrehash ¶
func RawTransactionWithDataPrehash() []byte
RawTransactionWithDataPrehash Return the sha3-256 prehash for RawTransactionWithData Do not write to the []byte returned
func Sha3256Hash ¶
Sha3256Hash takes a hash of the given sets of bytes
func StrToBigInt ¶
StrToBigInt converts a string to a big.Int
func StrToUint64 ¶
StrToUint64 converts a string to a uint64
Types ¶
type Account ¶
Account is a wrapper for a signer, handling the AccountAddress and signing
func NewAccountFromSigner ¶
func NewAccountFromSigner(signer crypto.Signer, accountAddress ...AccountAddress) (*Account, error)
NewAccountFromSigner creates an account from a Signer, which is most commonly a private key
func NewEd25519Account ¶
NewEd25519Account creates a legacy Ed25519 account, this is most commonly used in wallets
func NewEd25519SingleSenderAccount ¶
NewEd25519SingleSenderAccount creates a single signer Ed25519 account
func NewSecp256k1Account ¶
NewSecp256k1Account creates a Secp256k1 account
type AccountAddress ¶
type AccountAddress = types.AccountAddress
AccountAddress is a 32 byte address on the Aptos blockchain It can represent an Object, an Account, and much more.
func ConvertToAddress ¶
func ConvertToAddress(arg any) (*AccountAddress, error)
type AccountInfo ¶
type AccountInfo struct {
SequenceNumberStr string `json:"sequence_number"`
AuthenticationKeyHex string `json:"authentication_key"`
}
AccountInfo is returned from calls to #Account()
func (AccountInfo) AuthenticationKey ¶
func (ai AccountInfo) AuthenticationKey() ([]byte, error)
AuthenticationKey Hex decode of AuthenticationKeyHex
func (AccountInfo) SequenceNumber ¶
func (ai AccountInfo) SequenceNumber() (uint64, error)
SequenceNumber ParseUint of SequenceNumberStr
type AccountResourceInfo ¶
type AccountResourceInfo struct {
// e.g. "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>"
Type string `json:"type"`
// Decoded from Move contract data, could really be anything
Data map[string]any `json:"data"`
}
AccountResourceInfo is returned by #AccountResource() and #AccountResources()
type AccountResourceRecord ¶
type AccountResourceRecord struct {
// Account::Module::Name
Tag StructTag
// BCS data as stored by Move contract
Data []byte
}
AccountResourceRecord DeserializeSequence[AccountResourceRecord](bcs) approximates the Rust side BTreeMap<StructTag,Vec<u8>> They should BCS the same with a prefix Uleb128 length followed by (StructTag,[]byte) pairs.
func (*AccountResourceRecord) MarshalBCS ¶
func (aar *AccountResourceRecord) MarshalBCS(ser *bcs.Serializer)
func (*AccountResourceRecord) UnmarshalBCS ¶
func (aar *AccountResourceRecord) UnmarshalBCS(des *bcs.Deserializer)
type AdditionalSigners ¶
type AdditionalSigners []AccountAddress
AdditionalSigners will set the additional signers for a transaction
type AddressTag ¶
type AddressTag struct{}
AddressTag represents the address type in Move
func (*AddressTag) GetType ¶
func (xt *AddressTag) GetType() TypeTagVariant
func (*AddressTag) MarshalBCS ¶
func (xt *AddressTag) MarshalBCS(_ *bcs.Serializer)
region AddressTag bcs.Struct
func (*AddressTag) UnmarshalBCS ¶
func (xt *AddressTag) UnmarshalBCS(_ *bcs.Deserializer)
type AptosClient ¶
type AptosClient interface {
AptosRpcClient
AptosIndexerClient
AptosFaucetClient
}
AptosClient is an interface for all functionality on the Client. It is a combination of AptosRpcClient, AptosIndexerClient, and AptosFaucetClient for the purposes of mocking and convenience.
type AptosFaucetClient ¶
type AptosFaucetClient interface {
// Fund Uses the faucet to fund an address, only applies to non-production networks
Fund(address AccountAddress, amount uint64) error
}
AptosFaucetClient is an interface for all functionality on the Client that is Faucet related. Its main implementation is FaucetClient
type AptosIndexerClient ¶
type AptosIndexerClient interface {
// QueryIndexer queries the indexer using GraphQL to fill the `query` struct with data. See examples in the indexer client on how to make queries
//
// var out []CoinBalance
// var q struct {
// Current_coin_balances []struct {
// CoinType string `graphql:"coin_type"`
// Amount uint64
// OwnerAddress string `graphql:"owner_address"`
// } `graphql:"current_coin_balances(where: {owner_address: {_eq: $address}})"`
// }
// variables := map[string]any{
// "address": address.StringLong(),
// }
// err := client.QueryIndexer(&q, variables)
// if err != nil {
// return nil, err
// }
//
// for _, coin := range q.Current_coin_balances {
// out = append(out, CoinBalance{
// CoinType: coin.CoinType,
// Amount: coin.Amount,
// })
// }
//
// return out, nil
QueryIndexer(query any, variables map[string]any, options ...graphql.Option) error
// GetProcessorStatus returns the ledger version up to which the processor has processed
GetProcessorStatus(processorName string) (uint64, error)
// GetCoinBalances gets the balances of all coins associated with a given address
GetCoinBalances(address AccountAddress) ([]CoinBalance, error)
}
AptosIndexerClient is an interface for all functionality on the Client that is Indexer related. Its main implementation is IndexerClient
type AptosRpcClient ¶
type AptosRpcClient interface {
// SetTimeout adjusts the HTTP client timeout
//
// client.SetTimeout(5 * time.Millisecond)
SetTimeout(timeout time.Duration)
// SetHeader sets the header for all future requests
//
// client.SetHeader("Authorization", "Bearer abcde")
SetHeader(key string, value string)
// RemoveHeader removes the header from being automatically set all future requests.
//
// client.RemoveHeader("Authorization")
RemoveHeader(key string)
// Info Retrieves the node info about the network and it's current state
Info() (NodeInfo, error)
// Account Retrieves information about the account such as [SequenceNumber] and [crypto.AuthenticationKey]
Account(address AccountAddress, ledgerVersion ...uint64) (AccountInfo, error)
// AccountResource Retrieves a single resource given its struct name.
//
// address := AccountOne
// dataMap, _ := client.AccountResource(address, "0x1::coin::CoinStore")
//
// Can also fetch at a specific ledger version
//
// address := AccountOne
// dataMap, _ := client.AccountResource(address, "0x1::coin::CoinStore", 1)
AccountResource(address AccountAddress, resourceType string, ledgerVersion ...uint64) (map[string]any, error)
// AccountResources fetches resources for an account into a JSON-like map[string]any in AccountResourceInfo.Data
// For fetching raw Move structs as BCS, See #AccountResourcesBCS
//
// address := AccountOne
// dataMap, _ := client.AccountResources(address)
//
// Can also fetch at a specific ledger version
//
// address := AccountOne
// dataMap, _ := client.AccountResource(address, 1)
AccountResources(address AccountAddress, ledgerVersion ...uint64) ([]AccountResourceInfo, error)
// AccountResourcesBCS fetches account resources as raw Move struct BCS blobs in AccountResourceRecord.Data []byte
AccountResourcesBCS(address AccountAddress, ledgerVersion ...uint64) ([]AccountResourceRecord, error)
// AccountModule fetches a single account module's bytecode and ABI from on-chain state.
AccountModule(address AccountAddress, moduleName string, ledgerVersion ...uint64) (*api.MoveBytecode, error)
// EntryFunctionWithArgs generates an EntryFunction from on-chain Module ABI, and converts simple inputs to BCS encoded ones.
EntryFunctionWithArgs(moduleAddress AccountAddress, moduleName string, functionName string, typeArgs []any, args []any) (*EntryFunction, error)
// BlockByHeight fetches a block by height
//
// block, _ := client.BlockByHeight(1, false)
//
// Can also fetch with transactions
//
// block, _ := client.BlockByHeight(1, true)
BlockByHeight(blockHeight uint64, withTransactions bool) (*api.Block, error)
// BlockByVersion fetches a block by ledger version
//
// block, _ := client.BlockByVersion(123, false)
//
// Can also fetch with transactions
//
// block, _ := client.BlockByVersion(123, true)
BlockByVersion(ledgerVersion uint64, withTransactions bool) (*api.Block, error)
// TransactionByHash gets info on a transaction
// The transaction may be pending or recently committed.
//
// data, err := client.TransactionByHash("0xabcd")
// if err != nil {
// if httpErr, ok := err.(aptos.HttpError) {
// if httpErr.StatusCode == 404 {
// // if we're sure this has been submitted, assume it is still pending elsewhere in the mempool
// }
// }
// } else {
// if data["type"] == "pending_transaction" {
// // known to local mempool, but not committed yet
// }
// }
TransactionByHash(txnHash string) (*api.Transaction, error)
// WaitTransactionByHash waits for a transaction to be confirmed by its hash.
// This function allows you to monitor the status of a transaction until it is finalized.
WaitTransactionByHash(txnHash string) (*api.Transaction, error)
// TransactionByVersion gets info on a transaction from its LedgerVersion. It must have been
// committed to have a ledger version
//
// data, err := client.TransactionByVersion("0xabcd")
// if err != nil {
// if httpErr, ok := err.(aptos.HttpError) {
// if httpErr.StatusCode == 404 {
// // if we're sure this has been submitted, the full node might not be caught up to this version yet
// }
// }
// }
TransactionByVersion(version uint64) (*api.CommittedTransaction, error)
// PollForTransaction waits up to 10 seconds for a transaction to be done, polling at 10Hz
// Accepts options PollPeriod and PollTimeout which should wrap time.Duration values.
// Not just a degenerate case of PollForTransactions, it may return additional information for the single transaction polled.
PollForTransaction(hash string, options ...any) (*api.UserTransaction, error)
// PollForTransactions Waits up to 10 seconds for transactions to be done, polling at 10Hz
// Accepts options PollPeriod and PollTimeout which should wrap time.Duration values.
//
// hashes := []string{"0x1234", "0x4567"}
// err := client.PollForTransactions(hashes)
//
// Can additionally configure different options
//
// hashes := []string{"0x1234", "0x4567"}
// err := client.PollForTransactions(hashes, PollPeriod(500 * time.Milliseconds), PollTimeout(5 * time.Seconds))
PollForTransactions(txnHashes []string, options ...any) error
// WaitForTransaction Do a long-GET for one transaction and wait for it to complete
//
// data, err := client.WaitForTransaction("0x1234")
WaitForTransaction(txnHash string, options ...any) (*api.UserTransaction, error)
// Transactions Get recent transactions.
// Start is a version number. Nil for most recent transactions.
// Limit is a number of transactions to return. 'about a hundred' by default.
//
// client.Transactions(0, 2) // Returns 2 transactions
// client.Transactions(1, 100) // Returns 100 transactions
Transactions(start *uint64, limit *uint64) ([]*api.CommittedTransaction, error)
// AccountTransactions Get transactions associated with an account.
// Start is a version number. Nil for most recent transactions.
// Limit is a number of transactions to return. 'about a hundred' by default.
//
// client.AccountTransactions(AccountOne, 0, 2) // Returns 2 transactions for 0x1
// client.AccountTransactions(AccountOne, 1, 100) // Returns 100 transactions for 0x1
AccountTransactions(address AccountAddress, start *uint64, limit *uint64) ([]*api.CommittedTransaction, error)
// EventsByHandle retrieves events by event handle and field name for a given account.
//
// Arguments:
// - account - The account address to get events for
// - eventHandle - The event handle struct tag
// - fieldName - The field in the event handle struct
// - start - The starting sequence number. nil for most recent events
// - limit - The number of events to return, 100 by default
EventsByHandle(
account AccountAddress,
eventHandle string,
fieldName string,
start *uint64,
limit *uint64,
) ([]*api.Event, error)
// SubmitTransaction Submits an already signed transaction to the blockchain
//
// sender := NewEd25519Account()
// txnPayload := TransactionPayload{
// Payload: &EntryFunction{
// Module: ModuleId{
// Address: AccountOne,
// Name: "aptos_account",
// },
// Function: "transfer",
// ArgTypes: []TypeTag{},
// Args: [][]byte{
// dest[:],
// amountBytes,
// },
// }
// }
// rawTxn, _ := client.BuildTransaction(sender.AccountAddress(), txnPayload)
// signedTxn, _ := sender.SignTransaction(rawTxn)
// submitResponse, err := client.SubmitTransaction(signedTxn)
SubmitTransaction(signedTransaction *SignedTransaction) (*api.SubmitTransactionResponse, error)
// BatchSubmitTransaction submits a collection of signed transactions to the network in a single request
//
// It will return the responses in the same order as the input transactions that failed. If the response is empty, then
// all transactions succeeded.
//
// sender := NewEd25519Account()
// txnPayload := TransactionPayload{
// Payload: &EntryFunction{
// Module: ModuleId{
// Address: AccountOne,
// Name: "aptos_account",
// },
// Function: "transfer",
// ArgTypes: []TypeTag{},
// Args: [][]byte{
// dest[:],
// amountBytes,
// },
// }
// }
// rawTxn, _ := client.BuildTransaction(sender.AccountAddress(), txnPayload)
// signedTxn, _ := sender.SignTransaction(rawTxn)
// submitResponse, err := client.BatchSubmitTransaction([]*SignedTransaction{signedTxn})
BatchSubmitTransaction(signedTxns []*SignedTransaction) (*api.BatchSubmitTransactionResponse, error)
// SimulateTransaction Simulates a raw transaction without sending it to the blockchain
//
// sender := NewEd25519Account()
// txnPayload := TransactionPayload{
// Payload: &EntryFunction{
// Module: ModuleId{
// Address: AccountOne,
// Name: "aptos_account",
// },
// Function: "transfer",
// ArgTypes: []TypeTag{},
// Args: [][]byte{
// dest[:],
// amountBytes,
// },
// }
// }
// rawTxn, _ := client.BuildTransaction(sender.AccountAddress(), txnPayload)
// simResponse, err := client.SimulateTransaction(rawTxn, sender)
SimulateTransaction(rawTxn *RawTransaction, sender TransactionSigner, options ...any) ([]*api.UserTransaction, error)
// SimulateTransactionMultiAgent simulates a transaction as fee payer or multi agent
SimulateTransactionMultiAgent(rawTxn *RawTransactionWithData, sender TransactionSigner, options ...any) ([]*api.UserTransaction, error)
// GetChainId Retrieves the ChainId of the network
// Note this will be cached forever, or taken directly from the config
GetChainId() (uint8, error)
// BuildTransaction Builds a raw transaction from the payload and fetches any necessary information from on-chain
//
// sender := NewEd25519Account()
// txnPayload := TransactionPayload{
// Payload: &EntryFunction{
// Module: ModuleId{
// Address: AccountOne,
// Name: "aptos_account",
// },
// Function: "transfer",
// ArgTypes: []TypeTag{},
// Args: [][]byte{
// dest[:],
// amountBytes,
// },
// }
// }
// rawTxn, err := client.BuildTransaction(sender.AccountAddress(), txnPayload)
BuildTransaction(sender AccountAddress, payload TransactionPayload, options ...any) (*RawTransaction, error)
// BuildTransactionMultiAgent Builds a raw transaction for MultiAgent or FeePayer from the payload and fetches any necessary information from on-chain
//
// sender := NewEd25519Account()
// txnPayload := TransactionPayload{
// Payload: &EntryFunction{
// Module: ModuleId{
// Address: AccountOne,
// Name: "aptos_account",
// },
// Function: "transfer",
// ArgTypes: []TypeTag{},
// Args: [][]byte{
// dest[:],
// amountBytes,
// },
// }
// }
// rawTxn, err := client.BuildTransactionMultiAgent(sender.AccountAddress(), txnPayload, FeePayer(AccountZero))
BuildTransactionMultiAgent(sender AccountAddress, payload TransactionPayload, options ...any) (*RawTransactionWithData, error)
// BuildSignAndSubmitTransaction Convenience function to do all three in one
// for more configuration, please use them separately
//
// sender := NewEd25519Account()
// txnPayload := TransactionPayload{
// Payload: &EntryFunction{
// Module: ModuleId{
// Address: AccountOne,
// Name: "aptos_account",
// },
// Function: "transfer",
// ArgTypes: []TypeTag{},
// Args: [][]byte{
// dest[:],
// amountBytes,
// },
// }
// }
// submitResponse, err := client.BuildSignAndSubmitTransaction(sender, txnPayload)
BuildSignAndSubmitTransaction(sender TransactionSigner, payload TransactionPayload, options ...any) (*api.SubmitTransactionResponse, error)
// View Runs a view function on chain returning a list of return values.
//
// address := AccountOne
// payload := &ViewPayload{
// Module: ModuleId{
// Address: AccountOne,
// Name: "coin",
// },
// Function: "balance",
// ArgTypes: []TypeTag{AptosCoinTypeTag},
// Args: [][]byte{address[:]},
// }
// vals, err := client.aptosClient.View(payload)
// balance := StrToU64(vals.(any[])[0].(string))
View(payload *ViewPayload, ledgerVersion ...uint64) ([]any, error)
// EstimateGasPrice Retrieves the gas estimate from the network.
EstimateGasPrice() (EstimateGasInfo, error)
// AccountAPTBalance retrieves the APT balance in the account
AccountAPTBalance(address AccountAddress, ledgerVersion ...uint64) (uint64, error)
// NodeAPIHealthCheck checks if the node is within durationSecs of the current time, if not provided the node default is used
NodeAPIHealthCheck(durationSecs ...uint64) (api.HealthCheckResponse, error)
}
AptosRpcClient is an interface for all functionality on the Client that is Node RPC related. Its main implementation is NodeClient
type BoolTag ¶
type BoolTag struct{}
BoolTag represents the bool type in Move
func (*BoolTag) GetType ¶
func (xt *BoolTag) GetType() TypeTagVariant
func (*BoolTag) MarshalBCS ¶
func (xt *BoolTag) MarshalBCS(_ *bcs.Serializer)
region BoolTag bcs.struct
func (*BoolTag) UnmarshalBCS ¶
func (xt *BoolTag) UnmarshalBCS(_ *bcs.Deserializer)
type ChainIdOption ¶
type ChainIdOption uint8
ChainIdOption will set the chain ID for a transaction TODO: This one may want to be removed / renamed?
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a facade over the multiple types of underlying clients, as the user doesn't actually care where the data comes from. It will be then handled underneath
To create a new client, please use NewClient. An example below for Devnet:
client := NewClient(DevnetConfig)
Implements AptosClient
func NewClient ¶
func NewClient(config NetworkConfig, options ...any) (*Client, error)
NewClient Creates a new client with a specific network config that can be extended in the future
func (*Client) Account ¶
func (client *Client) Account(address AccountAddress, ledgerVersion ...uint64) (AccountInfo, error)
Account Retrieves information about the account such as SequenceNumber and crypto.AuthenticationKey
func (*Client) AccountAPTBalance ¶
func (client *Client) AccountAPTBalance(address AccountAddress, ledgerVersion ...uint64) (uint64, error)
AccountAPTBalance retrieves the APT balance in the account
func (*Client) AccountModule ¶
func (client *Client) AccountModule(address AccountAddress, moduleName string, ledgerVersion ...uint64) (*api.MoveBytecode, error)
func (*Client) AccountResource ¶
func (client *Client) AccountResource(address AccountAddress, resourceType string, ledgerVersion ...uint64) (map[string]any, error)
AccountResource Retrieves a single resource given its struct name.
address := AccountOne dataMap, _ := client.AccountResource(address, "0x1::coin::CoinStore")
Can also fetch at a specific ledger version
address := AccountOne dataMap, _ := client.AccountResource(address, "0x1::coin::CoinStore", 1)
func (*Client) AccountResources ¶
func (client *Client) AccountResources(address AccountAddress, ledgerVersion ...uint64) ([]AccountResourceInfo, error)
AccountResources fetches resources for an account into a JSON-like map[string]any in AccountResourceInfo.Data For fetching raw Move structs as BCS, See #AccountResourcesBCS
address := AccountOne dataMap, _ := client.AccountResources(address)
Can also fetch at a specific ledger version
address := AccountOne dataMap, _ := client.AccountResource(address, 1)
func (*Client) AccountResourcesBCS ¶
func (client *Client) AccountResourcesBCS(address AccountAddress, ledgerVersion ...uint64) ([]AccountResourceRecord, error)
AccountResourcesBCS fetches account resources as raw Move struct BCS blobs in AccountResourceRecord.Data []byte
func (*Client) AccountTransactions ¶
func (client *Client) AccountTransactions(address AccountAddress, start *uint64, limit *uint64) ([]*api.CommittedTransaction, error)
AccountTransactions Get transactions associated with an account. Start is a version number. Nil for most recent transactions. Limit is a number of transactions to return. 'about a hundred' by default.
client.AccountTransactions(AccountOne, 0, 2) // Returns 2 transactions for 0x1 client.AccountTransactions(AccountOne, 1, 100) // Returns 100 transactions for 0x1
func (*Client) BatchSubmitTransaction ¶
func (client *Client) BatchSubmitTransaction(signedTxns []*SignedTransaction) (*api.BatchSubmitTransactionResponse, error)
BatchSubmitTransaction submits a collection of signed transactions to the network in a single request
It will return the responses in the same order as the input transactions that failed. If the response is empty, then all transactions succeeded.
sender := NewEd25519Account()
txnPayload := TransactionPayload{
Payload: &EntryFunction{
Module: ModuleId{
Address: AccountOne,
Name: "aptos_account",
},
Function: "transfer",
ArgTypes: []TypeTag{},
Args: [][]byte{
dest[:],
amountBytes,
},
}
}
rawTxn, _ := client.BuildTransaction(sender.AccountAddress(), txnPayload)
signedTxn, _ := sender.SignTransaction(rawTxn)
submitResponse, err := client.BatchSubmitTransaction([]*SignedTransaction{signedTxn})
func (*Client) BlockByHeight ¶
BlockByHeight fetches a block by height
block, _ := client.BlockByHeight(1, false)
Can also fetch with transactions
block, _ := client.BlockByHeight(1, true)
func (*Client) BlockByVersion ¶
func (client *Client) BlockByVersion(ledgerVersion uint64, withTransactions bool) (*api.Block, error)
BlockByVersion fetches a block by ledger version
block, _ := client.BlockByVersion(123, false)
Can also fetch with transactions
block, _ := client.BlockByVersion(123, true)
func (*Client) BuildSignAndSubmitTransaction ¶
func (client *Client) BuildSignAndSubmitTransaction(sender TransactionSigner, payload TransactionPayload, options ...any) (*api.SubmitTransactionResponse, error)
BuildSignAndSubmitTransaction Convenience function to do all three in one for more configuration, please use them separately
sender := NewEd25519Account()
txnPayload := TransactionPayload{
Payload: &EntryFunction{
Module: ModuleId{
Address: AccountOne,
Name: "aptos_account",
},
Function: "transfer",
ArgTypes: []TypeTag{},
Args: [][]byte{
dest[:],
amountBytes,
},
}
}
submitResponse, err := client.BuildSignAndSubmitTransaction(sender, txnPayload)
func (*Client) BuildSignAndSubmitTransactions ¶
func (client *Client) BuildSignAndSubmitTransactions( sender TransactionSigner, payloads chan TransactionBuildPayload, responses chan TransactionSubmissionResponse, buildOptions ...any, )
BuildSignAndSubmitTransactions starts up a goroutine to process transactions for a single [TransactionSender] Closes output chan `responses` on completion of input chan `payloads`.
func (*Client) BuildSignAndSubmitTransactionsWithSignFunction ¶
func (client *Client) BuildSignAndSubmitTransactionsWithSignFunction( sender AccountAddress, payloads chan TransactionBuildPayload, responses chan TransactionSubmissionResponse, sign func(rawTxn RawTransactionImpl) (*SignedTransaction, error), buildOptions ...any, )
BuildSignAndSubmitTransactionsWithSignFunction allows for signing with a custom function
Closes output chan `responses` on completion of input chan `payloads`.
This enables the ability to do fee payer, and other approaches while staying concurrent
func Example() {
client := NewNodeClient()
sender := NewEd25519Account()
feePayer := NewEd25519Account()
payloads := make(chan TransactionBuildPayload)
responses := make(chan TransactionSubmissionResponse)
signingFunc := func(rawTxn RawTransactionImpl) (*SignedTransaction, error) {
switch rawTxn.(type) {
case *RawTransaction:
return nil, fmt.Errorf("only fee payer supported")
case *RawTransactionWithData:
rawTxnWithData := rawTxn.(*RawTransactionWithData)
switch rawTxnWithData.Variant {
case MultiAgentRawTransactionWithDataVariant:
return nil, fmt.Errorf("multi agent not supported, please provide a fee payer function")
case MultiAgentWithFeePayerRawTransactionWithDataVariant:
rawTxnWithData.Sign(sender)
txn, ok := rawTxnWithData.ToFeePayerTransaction()
default:
return nil, fmt.Errorf("unsupported rawTransactionWithData type")
}
default:
return nil, fmt.Errorf("unsupported rawTransactionImpl type")
}
}
// startup worker
go client.BuildSignAndSubmitTransactionsWithSignFunction(
sender,
payloads,
responses,
signingFunc
)
// Here add payloads, and wiating on resposnes
}
func (*Client) BuildTransaction ¶
func (client *Client) BuildTransaction(sender AccountAddress, payload TransactionPayload, options ...any) (*RawTransaction, error)
BuildTransaction Builds a raw transaction from the payload and fetches any necessary information from on-chain
sender := NewEd25519Account()
txnPayload := TransactionPayload{
Payload: &EntryFunction{
Module: ModuleId{
Address: AccountOne,
Name: "aptos_account",
},
Function: "transfer",
ArgTypes: []TypeTag{},
Args: [][]byte{
dest[:],
amountBytes,
},
}
}
rawTxn, err := client.BuildTransaction(sender.AccountAddress(), txnPayload)
func (*Client) BuildTransactionMultiAgent ¶
func (client *Client) BuildTransactionMultiAgent(sender AccountAddress, payload TransactionPayload, options ...any) (*RawTransactionWithData, error)
BuildTransactionMultiAgent Builds a raw transaction for MultiAgent or FeePayer from the payload and fetches any necessary information from on-chain
sender := NewEd25519Account()
txnPayload := TransactionPayload{
Payload: &EntryFunction{
Module: ModuleId{
Address: AccountOne,
Name: "aptos_account",
},
Function: "transfer",
ArgTypes: []TypeTag{},
Args: [][]byte{
dest[:],
amountBytes,
},
}
}
rawTxn, err := client.BuildTransactionMultiAgent(sender.AccountAddress(), txnPayload, FeePayer(AccountZero))
func (*Client) BuildTransactions ¶
func (client *Client) BuildTransactions(sender AccountAddress, payloads chan TransactionBuildPayload, responses chan TransactionBuildResponse, setSequenceNumber chan uint64, options ...any)
BuildTransactions start a goroutine to process TransactionPayload and spit out RawTransactionImpl.
func (*Client) EntryFunctionWithArgs ¶
func (client *Client) EntryFunctionWithArgs(address AccountAddress, moduleName string, functionName string, typeArgs []any, args []any) (*EntryFunction, error)
func (*Client) EstimateGasPrice ¶
func (client *Client) EstimateGasPrice() (EstimateGasInfo, error)
EstimateGasPrice Retrieves the gas estimate from the network.
func (*Client) EventsByHandle ¶
func (client *Client) EventsByHandle(account AccountAddress, eventHandle string, fieldName string, start *uint64, limit *uint64) ([]*api.Event, error)
EventsByHandle Get events by handle and field name for an account. Start is a sequence number. Nil for most recent events. Limit is a number of events to return, 100 by default.
client.EventsByHandle(AccountOne, "0x2", "transfer", 0, 2) // Returns 2 events client.EventsByHandle(AccountOne, "0x2", "transfer", 1, 100) // Returns 100 events
func (*Client) FetchNextMultisigAddress ¶
func (client *Client) FetchNextMultisigAddress(address AccountAddress) (*AccountAddress, error)
FetchNextMultisigAddress retrieves the next multisig address to be created from the given account
func (*Client) Fund ¶
func (client *Client) Fund(address AccountAddress, amount uint64) error
Fund Uses the faucet to fund an address, only applies to non-production networks
func (*Client) GetChainId ¶
GetChainId Retrieves the ChainId of the network Note this will be cached forever, or taken directly from the config
func (*Client) GetCoinBalances ¶
func (client *Client) GetCoinBalances(address AccountAddress) ([]CoinBalance, error)
GetCoinBalances gets the balances of all coins associated with a given address
func (*Client) GetProcessorStatus ¶
GetProcessorStatus returns the ledger version up to which the processor has processed
func (*Client) NodeAPIHealthCheck ¶
func (client *Client) NodeAPIHealthCheck(durationSecs ...uint64) (api.HealthCheckResponse, error)
NodeAPIHealthCheck checks if the node is within durationSecs of the current time, if not provided the node default is used
func (*Client) PollForTransaction ¶
PollForTransaction Waits up to 10 seconds for as single transaction to be done, polling at 10Hz
func (*Client) PollForTransactions ¶
PollForTransactions Waits up to 10 seconds for transactions to be done, polling at 10Hz Accepts options PollPeriod and PollTimeout which should wrap time.Duration values.
hashes := []string{"0x1234", "0x4567"}
err := client.PollForTransactions(hashes)
Can additionally configure different options
hashes := []string{"0x1234", "0x4567"}
err := client.PollForTransactions(hashes, PollPeriod(500 * time.Milliseconds), PollTimeout(5 * time.Seconds))
func (*Client) QueryIndexer ¶
func (client *Client) QueryIndexer(query any, variables map[string]any, options ...graphql.Option) error
QueryIndexer queries the indexer using GraphQL to fill the `query` struct with data. See examples in the indexer client on how to make queries
var out []CoinBalance
var q struct {
Current_coin_balances []struct {
CoinType string `graphql:"coin_type"`
Amount uint64
OwnerAddress string `graphql:"owner_address"`
} `graphql:"current_coin_balances(where: {owner_address: {_eq: $address}})"`
}
variables := map[string]any{
"address": address.StringLong(),
}
err := client.QueryIndexer(&q, variables)
if err != nil {
return nil, err
}
for _, coin := range q.Current_coin_balances {
out = append(out, CoinBalance{
CoinType: coin.CoinType,
Amount: coin.Amount,
})
}
return out, nil
func (*Client) RemoveHeader ¶
RemoveHeader removes the header from being automatically set all future requests.
client.RemoveHeader("Authorization")
func (*Client) SetHeader ¶
SetHeader sets the header for all future requests
client.SetHeader("Authorization", "Bearer abcde")
func (*Client) SetTimeout ¶
SetTimeout adjusts the HTTP client timeout
client.SetTimeout(5 * time.Millisecond)
func (*Client) SimulateTransaction ¶
func (client *Client) SimulateTransaction(rawTxn *RawTransaction, sender TransactionSigner, options ...any) ([]*api.UserTransaction, error)
SimulateTransaction Simulates a raw transaction without sending it to the blockchain
sender := NewEd25519Account()
txnPayload := TransactionPayload{
Payload: &EntryFunction{
Module: ModuleId{
Address: AccountOne,
Name: "aptos_account",
},
Function: "transfer",
ArgTypes: []TypeTag{},
Args: [][]byte{
dest[:],
amountBytes,
},
}
}
rawTxn, _ := client.BuildTransaction(sender.AccountAddress(), txnPayload)
simResponse, err := client.SimulateTransaction(rawTxn, sender)
func (*Client) SimulateTransactionMultiAgent ¶
func (client *Client) SimulateTransactionMultiAgent(rawTxn *RawTransactionWithData, sender TransactionSigner, options ...any) ([]*api.UserTransaction, error)
SimulateTransactionMultiAgent simulates a transaction as fee payer or multi agent
func (*Client) SubmitTransaction ¶
func (client *Client) SubmitTransaction(signedTransaction *SignedTransaction) (*api.SubmitTransactionResponse, error)
SubmitTransaction Submits an already signed transaction to the blockchain
sender := NewEd25519Account()
txnPayload := TransactionPayload{
Payload: &EntryFunction{
Module: ModuleId{
Address: AccountOne,
Name: "aptos_account",
},
Function: "transfer",
ArgTypes: []TypeTag{},
Args: [][]byte{
dest[:],
amountBytes,
},
}
}
rawTxn, _ := client.BuildTransaction(sender.AccountAddress(), txnPayload)
signedTxn, _ := sender.SignTransaction(rawTxn)
submitResponse, err := client.SubmitTransaction(signedTxn)
func (*Client) SubmitTransactions ¶
func (client *Client) SubmitTransactions(requests chan TransactionSubmissionRequest, responses chan TransactionSubmissionResponse)
SubmitTransactions consumes signed transactions, submits to aptos-node, yields responses. closes output chan `responses` when input chan `signedTxns` is closed.
func (*Client) TransactionByHash ¶
func (client *Client) TransactionByHash(txnHash string) (*api.Transaction, error)
TransactionByHash gets info on a transaction The transaction may be pending or recently committed.
data, err := client.TransactionByHash("0xabcd")
if err != nil {
if httpErr, ok := err.(aptos.HttpError) {
if httpErr.StatusCode == 404 {
// if we're sure this has been submitted, assume it is still pending elsewhere in the mempool
}
}
} else {
if data["type"] == "pending_transaction" {
// known to local mempool, but not committed yet
}
}
func (*Client) TransactionByVersion ¶
func (client *Client) TransactionByVersion(version uint64) (*api.CommittedTransaction, error)
TransactionByVersion gets info on a transaction from its LedgerVersion. It must have been committed to have a ledger version
data, err := client.TransactionByVersion("0xabcd")
if err != nil {
if httpErr, ok := err.(aptos.HttpError) {
if httpErr.StatusCode == 404 {
// if we're sure this has been submitted, the full node might not be caught up to this version yet
}
}
}
func (*Client) Transactions ¶
func (client *Client) Transactions(start *uint64, limit *uint64) ([]*api.CommittedTransaction, error)
Transactions Get recent transactions. Start is a version number. Nil for most recent transactions. Limit is a number of transactions to return. 'about a hundred' by default.
client.Transactions(0, 2) // Returns 2 transactions client.Transactions(1, 100) // Returns 100 transactions
func (*Client) View ¶
func (client *Client) View(payload *ViewPayload, ledgerVersion ...uint64) ([]any, error)
View Runs a view function on chain returning a list of return values.
address := AccountOne
payload := &ViewPayload{
Module: ModuleId{
Address: AccountOne,
Name: "coin",
},
Function: "balance",
ArgTypes: []TypeTag{AptosCoinTypeTag},
Args: [][]byte{address[:]},
}
vals, err := client.aptosClient.View(payload)
balance := StrToU64(vals.(any[])[0].(string))
func (*Client) WaitForTransaction ¶
func (client *Client) WaitForTransaction(txnHash string, options ...any) (*api.UserTransaction, error)
WaitForTransaction Do a long-GET for one transaction and wait for it to complete
data, err := client.WaitForTransaction("0x1234")
func (*Client) WaitTransactionByHash ¶
func (client *Client) WaitTransactionByHash(txnHash string) (*api.Transaction, error)
WaitTransactionByHash waits for a transaction to complete and returns it's data when finished.
type CoinBalance ¶
type ConcResponse ¶
ConcResponse is a concurrent response wrapper as a return type for all APIs. It is meant to specifically be used in channels.
type Ed25519TransactionAuthenticator ¶
type Ed25519TransactionAuthenticator struct {
Sender *crypto.AccountAuthenticator
}
Ed25519TransactionAuthenticator for legacy ED25519 accounts Implements TransactionAuthenticatorImpl, bcs.Struct
func (*Ed25519TransactionAuthenticator) MarshalBCS ¶
func (ea *Ed25519TransactionAuthenticator) MarshalBCS(ser *bcs.Serializer)
region Ed25519TransactionAuthenticator bcs.Struct
func (*Ed25519TransactionAuthenticator) UnmarshalBCS ¶
func (ea *Ed25519TransactionAuthenticator) UnmarshalBCS(des *bcs.Deserializer)
func (*Ed25519TransactionAuthenticator) Verify ¶
func (ea *Ed25519TransactionAuthenticator) Verify(msg []byte) bool
region Ed25519TransactionAuthenticator TransactionAuthenticatorImpl
type EntryFunction ¶
EntryFunction call a single published entry function arguments are ordered BCS encoded bytes
func CoinBatchTransferPayload ¶
func CoinBatchTransferPayload(coinType *TypeTag, dests []AccountAddress, amounts []uint64) (*EntryFunction, error)
CoinBatchTransferPayload builds an EntryFunction payload for transferring coins to multiple receivers
Args:
- coinType is the type of coin to transfer. If none is provided, it will transfer 0x1::aptos_coin:AptosCoin
- dests are the destination [AccountAddress]s
- amounts are the amount of coins to transfer per destination
func CoinTransferPayload ¶
func CoinTransferPayload(coinType *TypeTag, dest AccountAddress, amount uint64) (*EntryFunction, error)
CoinTransferPayload builds an EntryFunction payload for transferring coins
Args:
- coinType is the type of coin to transfer. If none is provided, it will transfer 0x1::aptos_coin:AptosCoin
- dest is the destination AccountAddress
- amount is the amount of coins to transfer
func EntryFunctionFromAbi ¶
func EntryFunctionFromAbi(abi any, moduleAddress AccountAddress, moduleName string, functionName string, typeArgs []any, args []any) (*EntryFunction, error)
func FungibleAssetPrimaryStoreTransferPayload ¶
func FungibleAssetPrimaryStoreTransferPayload(faMetadataAddress *AccountAddress, dest AccountAddress, amount uint64) (*EntryFunction, error)
FungibleAssetPrimaryStoreTransferPayload builds an EntryFunction payload to transfer between two primary stores. This is similar to CoinTransferPayload.
Args:
- faMetadataAddress is the AccountAddress of the metadata for the fungible asset
- dest is the destination AccountAddress
- amount is the amount of coins to transfer
Note: for now, if metadata is nil, then it will fail to build. But in the future, APT will be the default.
func FungibleAssetTransferPayload ¶
func FungibleAssetTransferPayload(faMetadataAddress *AccountAddress, source AccountAddress, dest AccountAddress, amount uint64) (*EntryFunction, error)
FungibleAssetTransferPayload builds an EntryFunction payload to transfer between two fungible asset stores
Args:
- faMetadataAddress is the AccountAddress of the metadata for the fungible asset
- source is the store AccountAddress to transfer from
- dest is the destination AccountAddress
- amount is the amount of coins to transfer
Note: for now, if metadata is nil, then it will fail to build. But in the future, APT will be the default
func MultisigAddOwnerPayload ¶
func MultisigAddOwnerPayload(owner AccountAddress) *EntryFunction
MultisigAddOwnerPayload creates a payload to add an owner from the multisig
func MultisigApprovePayload ¶
func MultisigApprovePayload(multisigAddress AccountAddress, transactionId uint64) (*EntryFunction, error)
MultisigApprovePayload generates a payload for approving a transaction on-chain. The caller must be an owner of the multisig
func MultisigChangeThresholdPayload ¶
func MultisigChangeThresholdPayload(numSignaturesRequired uint64) (*EntryFunction, error)
MultisigChangeThresholdPayload creates a payload to change the number of signatures required for a transaction to pass.
For example, changing a 2-of-3 to a 3-of-3, the value for numSignaturesRequired would be 3
func MultisigCreateAccountPayload ¶
func MultisigCreateAccountPayload(requiredSigners uint64, additionalAddresses []AccountAddress, metadataKeys []string, metadataValues []byte) (*EntryFunction, error)
MultisigCreateAccountPayload creates a payload for setting up a multisig
Required signers must be between 1 and the number of addresses total (sender + additional addresses). Metadata values must be BCS encoded values
func MultisigCreateTransactionPayload ¶
func MultisigCreateTransactionPayload(multisigAddress AccountAddress, payload *MultisigTransactionPayload) (*EntryFunction, error)
MultisigCreateTransactionPayload creates a transaction to be voted upon in an on-chain multisig
Note, this serializes an EntryFunction payload, and sends it as an argument in the transaction. If the entry function payload is large, use MultisigCreateTransactionPayloadWithHash. The advantage of this over the hash version, is visibility on-chain.
func MultisigCreateTransactionPayloadWithHash ¶
func MultisigCreateTransactionPayloadWithHash(multisigAddress AccountAddress, payload *MultisigTransactionPayload) (*EntryFunction, error)
MultisigCreateTransactionPayloadWithHash creates a transaction to be voted upon in an on-chain multisig
This differs from MultisigCreateTransactionPayload by instead taking a SHA3-256 hash of the payload and using that as the identifier of the transaction. The transaction intent will not be stored on-chain, only the hash of it.
func MultisigRejectPayload ¶
func MultisigRejectPayload(multisigAddress AccountAddress, transactionId uint64) (*EntryFunction, error)
MultisigRejectPayload generates a payload for rejecting a transaction on-chain. The caller must be an owner of the multisig
func MultisigRemoveOwnerPayload ¶
func MultisigRemoveOwnerPayload(owner AccountAddress) *EntryFunction
MultisigRemoveOwnerPayload creates a payload to remove an owner from the multisig
func (*EntryFunction) MarshalBCS ¶
func (sf *EntryFunction) MarshalBCS(ser *bcs.Serializer)
region EntryFunction bcs.Struct
func (*EntryFunction) PayloadType ¶
func (sf *EntryFunction) PayloadType() TransactionPayloadVariant
region EntryFunction TransactionPayloadImpl
func (*EntryFunction) UnmarshalBCS ¶
func (sf *EntryFunction) UnmarshalBCS(des *bcs.Deserializer)
type EstimateGasInfo ¶
type EstimateGasInfo struct {
DeprioritizedGasEstimate uint64 `json:"deprioritized_gas_estimate"` // DeprioritizedGasEstimate is the gas estimate for a transaction that is willing to be deprioritized and pay less
GasEstimate uint64 `json:"gas_estimate"` // GasEstimate is the gas estimate for a transaction that is willing to pay close to the median gas price
PrioritizedGasEstimate uint64 `json:"prioritized_gas_estimate"` // PrioritizedGasEstimate is the gas estimate for a transaction that is willing to pay more to be prioritized
}
EstimateGasInfo is returned by #EstimateGasPrice()
type EstimateGasUnitPrice ¶
type EstimateGasUnitPrice bool
EstimateGasUnitPrice estimates the gas unit price for a transaction
type EstimateMaxGasAmount ¶
type EstimateMaxGasAmount bool
EstimateMaxGasAmount estimates the max gas amount for a transaction
type EstimatePrioritizedGasUnitPrice ¶
type EstimatePrioritizedGasUnitPrice bool
EstimatePrioritizedGasUnitPrice estimates the prioritized gas unit price for a transaction
type ExpirationSeconds ¶
type ExpirationSeconds uint64
ExpirationSeconds will set the number of seconds from the current time to expire a transaction
type FaucetClient ¶
type FaucetClient struct {
// contains filtered or unexported fields
}
FaucetClient uses the underlying NodeClient to request for APT for gas on a network. This can only be used in a test network (e.g. Localnet, Devnet, Testnet)
func NewFaucetClient ¶
func NewFaucetClient(nodeClient *NodeClient, faucetUrl string) (*FaucetClient, error)
NewFaucetClient creates a new client specifically for requesting faucet funds
func (*FaucetClient) Fund ¶
func (faucetClient *FaucetClient) Fund(address AccountAddress, amount uint64) error
Fund account with the given amount of AptosCoin
type FeePayerTransactionAuthenticator ¶
type FeePayerTransactionAuthenticator struct {
Sender *crypto.AccountAuthenticator
SecondarySignerAddresses []AccountAddress
SecondarySigners []crypto.AccountAuthenticator
FeePayer *AccountAddress
FeePayerAuthenticator *crypto.AccountAuthenticator
}
region FeePayerTransactionAuthenticator
func (*FeePayerTransactionAuthenticator) MarshalBCS ¶
func (ea *FeePayerTransactionAuthenticator) MarshalBCS(ser *bcs.Serializer)
region FeePayerTransactionAuthenticator bcs.Struct
func (*FeePayerTransactionAuthenticator) UnmarshalBCS ¶
func (ea *FeePayerTransactionAuthenticator) UnmarshalBCS(des *bcs.Deserializer)
func (*FeePayerTransactionAuthenticator) Verify ¶
func (ea *FeePayerTransactionAuthenticator) Verify(msg []byte) bool
region FeePayerTransactionAuthenticator bcs.Struct
type FungibleAssetClient ¶
type FungibleAssetClient struct {
// contains filtered or unexported fields
}
FungibleAssetClient This is an example client around a single fungible asset
func NewFungibleAssetClient ¶
func NewFungibleAssetClient(client *Client, metadataAddress *AccountAddress) (*FungibleAssetClient, error)
NewFungibleAssetClient verifies the AccountAddress of the metadata exists when creating the client
func (*FungibleAssetClient) Balance ¶
func (client *FungibleAssetClient) Balance(storeAddress *AccountAddress, ledgerVersion ...uint64) (uint64, error)
Balance returns the balance of the store
func (*FungibleAssetClient) Decimals ¶
func (client *FungibleAssetClient) Decimals() (uint8, error)
Decimals returns the number of decimal places for the fungible asset
func (*FungibleAssetClient) IconUri ¶
func (client *FungibleAssetClient) IconUri() (string, error)
IconUri returns the URI of the icon for the fungible asset
func (*FungibleAssetClient) IsFrozen ¶
func (client *FungibleAssetClient) IsFrozen(storeAddress *AccountAddress, ledgerVersion ...uint64) (bool, error)
IsFrozen returns true if the store is frozen
func (*FungibleAssetClient) IsUntransferable ¶
func (client *FungibleAssetClient) IsUntransferable(storeAddress *AccountAddress, ledgerVersion ...uint64) (bool, error)
IsUntransferable returns true if the store can't be transferred
func (*FungibleAssetClient) Maximum ¶
func (client *FungibleAssetClient) Maximum(ledgerVersion ...uint64) (*big.Int, error)
Maximum returns the maximum possible supply of the fungible asset
func (*FungibleAssetClient) Name ¶
func (client *FungibleAssetClient) Name() (string, error)
Name returns the name of the fungible asset
func (*FungibleAssetClient) PrimaryBalance ¶
func (client *FungibleAssetClient) PrimaryBalance(owner *AccountAddress, ledgerVersion ...uint64) (uint64, error)
PrimaryBalance returns the balance of the primary store for the owner
func (*FungibleAssetClient) PrimaryIsFrozen ¶
func (client *FungibleAssetClient) PrimaryIsFrozen(owner *AccountAddress, ledgerVersion ...uint64) (bool, error)
PrimaryIsFrozen returns true if the primary store for the owner is frozen
func (*FungibleAssetClient) PrimaryStoreAddress ¶
func (client *FungibleAssetClient) PrimaryStoreAddress(owner *AccountAddress) (*AccountAddress, error)
PrimaryStoreAddress returns the AccountAddress of the primary store for the owner
Note that the primary store may not exist at the address. Use FungibleAssetClient.PrimaryStoreExists to check.
func (*FungibleAssetClient) PrimaryStoreExists ¶
func (client *FungibleAssetClient) PrimaryStoreExists(owner *AccountAddress) (bool, error)
PrimaryStoreExists returns true if the primary store for the owner exists
func (*FungibleAssetClient) ProjectUri ¶
func (client *FungibleAssetClient) ProjectUri() (string, error)
ProjectUri returns the URI of the project for the fungible asset
func (*FungibleAssetClient) StoreExists ¶
func (client *FungibleAssetClient) StoreExists(storeAddress *AccountAddress, ledgerVersion ...uint64) (bool, error)
StoreExists returns true if the store exists
func (*FungibleAssetClient) StoreMetadata ¶
func (client *FungibleAssetClient) StoreMetadata(storeAddress *AccountAddress, ledgerVersion ...uint64) (*AccountAddress, error)
StoreMetadata returns the AccountAddress of the metadata for the store
func (*FungibleAssetClient) Supply ¶
func (client *FungibleAssetClient) Supply(ledgerVersion ...uint64) (*big.Int, error)
Supply returns the total supply of the fungible asset
func (*FungibleAssetClient) Symbol ¶
func (client *FungibleAssetClient) Symbol() (string, error)
Symbol returns the symbol of the fungible asset
func (*FungibleAssetClient) Transfer ¶
func (client *FungibleAssetClient) Transfer(sender TransactionSigner, senderStore AccountAddress, receiverStore AccountAddress, amount uint64) (*SignedTransaction, error)
Transfer sends amount of the fungible asset from senderStore to receiverStore
func (*FungibleAssetClient) TransferPrimaryStore ¶
func (client *FungibleAssetClient) TransferPrimaryStore(sender TransactionSigner, receiverAddress AccountAddress, amount uint64) (*SignedTransaction, error)
TransferPrimaryStore sends amount of the fungible asset from the primary store of the sender to receiverAddress
type GasUnitPrice ¶
type GasUnitPrice uint64
GasUnitPrice will set the gas unit price in octas (1/10^8 APT) for a transaction
type GenericTag ¶
type GenericTag struct {
Num uint64
}
GenericTag represents a generic of a type in Move
func (*GenericTag) GetType ¶
func (xt *GenericTag) GetType() TypeTagVariant
func (*GenericTag) MarshalBCS ¶
func (xt *GenericTag) MarshalBCS(_ *bcs.Serializer)
TODO: Do we need a proper serialization here
func (*GenericTag) UnmarshalBCS ¶
func (xt *GenericTag) UnmarshalBCS(_ *bcs.Deserializer)
type HttpError ¶
type HttpError struct {
Status string // HTTP status e.g. "200 OK"
StatusCode int // HTTP status code e.g. 200
Header http.Header // HTTP headers
Method string // HTTP method e.g. "GET"
RequestUrl url.URL // URL of the request
Body []byte // Body of the response
}
HttpError is an error type that represents an error from a http request
func NewHttpError ¶
NewHttpError creates a new HttpError from a http.Response
type IndexerClient ¶
type IndexerClient struct {
// contains filtered or unexported fields
}
IndexerClient is a GraphQL client specifically for requesting for data from the Aptos indexer
func NewIndexerClient ¶
func NewIndexerClient(httpClient *http.Client, url string) *IndexerClient
NewIndexerClient creates a new client specifically for requesting data from the indexer
func (*IndexerClient) GetCoinBalances ¶
func (ic *IndexerClient) GetCoinBalances(address AccountAddress) ([]CoinBalance, error)
GetCoinBalances retrieve the coin balances for all coins owned by the address
func (*IndexerClient) GetProcessorStatus ¶
func (ic *IndexerClient) GetProcessorStatus(processorName string) (uint64, error)
GetProcessorStatus tells the most updated version of the transaction processor. This helps to determine freshness of data.
func (*IndexerClient) QueryIndexer ¶
func (ic *IndexerClient) QueryIndexer(query any, variables map[string]any, options ...graphql.Option) error
QueryIndexer is a generic function for making any GraphQL query against the indexer
func (*IndexerClient) WaitOnIndexer ¶
func (ic *IndexerClient) WaitOnIndexer(processorName string, requestedVersion uint64) error
WaitOnIndexer waits for the indexer processorName specified to catch up to the requestedVersion
type MaxGasAmount ¶
type MaxGasAmount uint64
MaxGasAmount will set the max gas amount in gas units for a transaction
type ModuleBundle ¶
type ModuleBundle struct{}
ModuleBundle is long deprecated and no longer used, but exist as an enum position in TransactionPayload
func (*ModuleBundle) MarshalBCS ¶
func (txn *ModuleBundle) MarshalBCS(ser *bcs.Serializer)
func (*ModuleBundle) PayloadType ¶
func (txn *ModuleBundle) PayloadType() TransactionPayloadVariant
func (*ModuleBundle) UnmarshalBCS ¶
func (txn *ModuleBundle) UnmarshalBCS(des *bcs.Deserializer)
type ModuleId ¶
type ModuleId struct {
Address AccountAddress
Name string
}
ModuleId the identifier for a module e.g. 0x1::coin
func (*ModuleId) MarshalBCS ¶
func (mod *ModuleId) MarshalBCS(ser *bcs.Serializer)
func (*ModuleId) UnmarshalBCS ¶
func (mod *ModuleId) UnmarshalBCS(des *bcs.Deserializer)
type MultiAgentRawTransactionWithData ¶
type MultiAgentRawTransactionWithData struct {
RawTxn *RawTransaction
SecondarySigners []AccountAddress
}
region MultiAgentRawTransactionWithData
func (*MultiAgentRawTransactionWithData) MarshalBCS ¶
func (txn *MultiAgentRawTransactionWithData) MarshalBCS(ser *bcs.Serializer)
region MultiAgentRawTransactionWithData bcs.Struct
func (*MultiAgentRawTransactionWithData) UnmarshalBCS ¶
func (txn *MultiAgentRawTransactionWithData) UnmarshalBCS(des *bcs.Deserializer)
type MultiAgentTransactionAuthenticator ¶
type MultiAgentTransactionAuthenticator struct {
Sender *crypto.AccountAuthenticator
SecondarySignerAddresses []AccountAddress
SecondarySigners []crypto.AccountAuthenticator
}
region MultiAgentTransactionAuthenticator
func (*MultiAgentTransactionAuthenticator) MarshalBCS ¶
func (ea *MultiAgentTransactionAuthenticator) MarshalBCS(ser *bcs.Serializer)
region MultiAgentTransactionAuthenticator bcs.Struct
func (*MultiAgentTransactionAuthenticator) UnmarshalBCS ¶
func (ea *MultiAgentTransactionAuthenticator) UnmarshalBCS(des *bcs.Deserializer)
func (*MultiAgentTransactionAuthenticator) Verify ¶
func (ea *MultiAgentTransactionAuthenticator) Verify(msg []byte) bool
region MultiAgentTransactionAuthenticator TransactionAuthenticatorImpl
type MultiAgentWithFeePayerRawTransactionWithData ¶
type MultiAgentWithFeePayerRawTransactionWithData struct {
RawTxn *RawTransaction
SecondarySigners []AccountAddress
FeePayer *AccountAddress
}
region MultiAgentWithFeePayerRawTransactionWithData
func (*MultiAgentWithFeePayerRawTransactionWithData) MarshalBCS ¶
func (txn *MultiAgentWithFeePayerRawTransactionWithData) MarshalBCS(ser *bcs.Serializer)
region MultiAgentWithFeePayerRawTransactionWithData bcs.Struct
func (*MultiAgentWithFeePayerRawTransactionWithData) UnmarshalBCS ¶
func (txn *MultiAgentWithFeePayerRawTransactionWithData) UnmarshalBCS(des *bcs.Deserializer)
type MultiEd25519TransactionAuthenticator ¶
type MultiEd25519TransactionAuthenticator struct {
Sender *crypto.AccountAuthenticator
}
region MultiEd25519TransactionAuthenticator
func (*MultiEd25519TransactionAuthenticator) MarshalBCS ¶
func (ea *MultiEd25519TransactionAuthenticator) MarshalBCS(ser *bcs.Serializer)
region MultiEd25519TransactionAuthenticator bcs.Struct
func (*MultiEd25519TransactionAuthenticator) UnmarshalBCS ¶
func (ea *MultiEd25519TransactionAuthenticator) UnmarshalBCS(des *bcs.Deserializer)
func (*MultiEd25519TransactionAuthenticator) Verify ¶
func (ea *MultiEd25519TransactionAuthenticator) Verify(msg []byte) bool
region Ed25519TransactionAuthenticator TransactionAuthenticatorImpl
type Multisig ¶
type Multisig struct {
MultisigAddress AccountAddress
Payload *MultisigTransactionPayload // Optional
}
Multisig is an on-chain multisig transaction, that calls an entry function associated
func (*Multisig) MarshalBCS ¶
func (sf *Multisig) MarshalBCS(ser *bcs.Serializer)
region Multisig bcs.Struct
func (*Multisig) PayloadType ¶
func (sf *Multisig) PayloadType() TransactionPayloadVariant
region Multisig TransactionPayloadImpl
func (*Multisig) UnmarshalBCS ¶
func (sf *Multisig) UnmarshalBCS(des *bcs.Deserializer)
type MultisigTransactionImpl ¶
type MultisigTransactionPayload ¶
type MultisigTransactionPayload struct {
Variant MultisigTransactionPayloadVariant
Payload MultisigTransactionImpl
}
MultisigTransactionPayload is an enum allowing for multiple types of transactions to be called via multisig
Note this does not implement TransactionPayloadImpl
func (*MultisigTransactionPayload) MarshalBCS ¶
func (sf *MultisigTransactionPayload) MarshalBCS(ser *bcs.Serializer)
region MultisigTransactionPayload bcs.Struct
func (*MultisigTransactionPayload) UnmarshalBCS ¶
func (sf *MultisigTransactionPayload) UnmarshalBCS(des *bcs.Deserializer)
type MultisigTransactionPayloadVariant ¶
type MultisigTransactionPayloadVariant uint32
region MultisigTransactionPayload
const (
MultisigTransactionPayloadVariantEntryFunction MultisigTransactionPayloadVariant = 0
)
type NetworkConfig ¶
type NetworkConfig struct {
Name string
ChainId uint8
NodeUrl string
IndexerUrl string
FaucetUrl string
}
NetworkConfig a configuration for the Client and which network to use. Use one of the preconfigured LocalnetConfig, DevnetConfig, TestnetConfig, or MainnetConfig unless you have your own full node.
Name, ChainId, IndexerUrl, FaucetUrl are not required.
If ChainId is 0, the ChainId wil be fetched on-chain If IndexerUrl or FaucetUrl are an empty string "", clients will not be made for them.
type NodeClient ¶
type NodeClient struct {
// contains filtered or unexported fields
}
NodeClient is a client for interacting with an Aptos node API
func NewNodeClient ¶
func NewNodeClient(rpcUrl string, chainId uint8) (*NodeClient, error)
NewNodeClient creates a new client for interacting with an Aptos node API
func NewNodeClientWithHttpClient ¶
func NewNodeClientWithHttpClient(rpcUrl string, chainId uint8, client *http.Client) (*NodeClient, error)
NewNodeClientWithHttpClient creates a new client for interacting with an Aptos node API with a custom http.Client
func (*NodeClient) Account ¶
func (rc *NodeClient) Account(address AccountAddress, ledgerVersion ...uint64) (AccountInfo, error)
Account gets information about an account for a given address
Optionally, a ledgerVersion can be given to get the account state at a specific ledger version
func (*NodeClient) AccountAPTBalance ¶
func (rc *NodeClient) AccountAPTBalance(account AccountAddress, ledgerVersion ...uint64) (uint64, error)
AccountAPTBalance fetches the balance of an account of APT. Response is in octas or 1/10^8 APT.
func (*NodeClient) AccountModule ¶
func (rc *NodeClient) AccountModule(address AccountAddress, moduleName string, ledgerVersion ...uint64) (*api.MoveBytecode, error)
AccountModule fetches a single account module's bytecode and ABI from on-chain state.
func (*NodeClient) AccountResource ¶
func (rc *NodeClient) AccountResource(address AccountAddress, resourceType string, ledgerVersion ...uint64) (map[string]any, error)
AccountResource fetches a resource for an account into a JSON-like map[string]any. Optionally, a ledgerVersion can be given to get the account state at a specific ledger version
For fetching raw Move structs as BCS, See #AccountResourceBCS
func (*NodeClient) AccountResources ¶
func (rc *NodeClient) AccountResources(address AccountAddress, ledgerVersion ...uint64) ([]AccountResourceInfo, error)
AccountResources fetches resources for an account into a JSON-like map[string]any in AccountResourceInfo.Data Optionally, a ledgerVersion can be given to get the account state at a specific ledger version For fetching raw Move structs as BCS, See #AccountResourcesBCS
func (*NodeClient) AccountResourcesBCS ¶
func (rc *NodeClient) AccountResourcesBCS(address AccountAddress, ledgerVersion ...uint64) ([]AccountResourceRecord, error)
AccountResourcesBCS fetches account resources as raw Move struct BCS blobs in AccountResourceRecord.Data []byte Optionally, a ledgerVersion can be given to get the account state at a specific ledger version
func (*NodeClient) AccountTransactions ¶
func (rc *NodeClient) AccountTransactions(account AccountAddress, start *uint64, limit *uint64) ([]*api.CommittedTransaction, error)
AccountTransactions Get recent transactions for an account
Arguments:
- start is a version number. Nil for most recent transactions.
- limit is a number of transactions to return. 'about a hundred' by default.
func (*NodeClient) BatchSubmitTransaction ¶
func (rc *NodeClient) BatchSubmitTransaction(signedTxns []*SignedTransaction) (*api.BatchSubmitTransactionResponse, error)
BatchSubmitTransaction submits a collection of signed transactions to the network in a single request
It will return the responses in the same order as the input transactions that failed. If the response is empty, then all transactions succeeded.
func (*NodeClient) BatchSubmitTransactions ¶
func (rc *NodeClient) BatchSubmitTransactions(requests chan TransactionSubmissionRequest, responses chan TransactionSubmissionResponse)
BatchSubmitTransactions consumes signed transactions, submits to aptos-node, yields responses. closes output chan `responses` when input chan `signedTxns` is closed.
func (*NodeClient) BlockByHeight ¶
BlockByHeight gets a block by block height
The function will fetch all transactions in the block if withTransactions is true.
func (*NodeClient) BlockByVersion ¶
func (rc *NodeClient) BlockByVersion(ledgerVersion uint64, withTransactions bool) (*api.Block, error)
BlockByVersion gets a block by a transaction's version number
Note that this is not the same as a block's height.
The function will fetch all transactions in the block if withTransactions is true.
func (*NodeClient) BuildSignAndSubmitTransaction ¶
func (rc *NodeClient) BuildSignAndSubmitTransaction(sender TransactionSigner, payload TransactionPayload, options ...any) (*api.SubmitTransactionResponse, error)
BuildSignAndSubmitTransaction builds, signs, and submits a transaction to the network
func (*NodeClient) BuildSignAndSubmitTransactions ¶
func (rc *NodeClient) BuildSignAndSubmitTransactions( sender TransactionSigner, payloads chan TransactionBuildPayload, responses chan TransactionSubmissionResponse, buildOptions ...any, )
BuildSignAndSubmitTransactions starts up a goroutine to process transactions for a single [TransactionSender] Closes output chan `responses` on completion of input chan `payloads`.
func (*NodeClient) BuildSignAndSubmitTransactionsWithSignFnAndWorkerPool ¶
func (rc *NodeClient) BuildSignAndSubmitTransactionsWithSignFnAndWorkerPool( sender AccountAddress, payloads chan TransactionBuildPayload, responses chan TransactionSubmissionResponse, sign func(rawTxn RawTransactionImpl) (*SignedTransaction, error), workerPoolConfig WorkerPoolConfig, buildOptions ...any, )
BuildSignAndSubmitTransactionsWithSignFnAndWorkerPool processes transactions using a fixed-size worker pool. It coordinates three stages of the pipeline: 1. Building transactions (BuildTransactions) 2. Signing transactions (worker pool) 3. Submitting transactions (SubmitTransactions)
func (*NodeClient) BuildSignAndSubmitTransactionsWithSignFunction ¶
func (rc *NodeClient) BuildSignAndSubmitTransactionsWithSignFunction( sender AccountAddress, payloads chan TransactionBuildPayload, responses chan TransactionSubmissionResponse, sign func(rawTxn RawTransactionImpl) (*SignedTransaction, error), buildOptions ...any, )
BuildSignAndSubmitTransactionsWithSignFunction allows for signing with a custom function
Closes output chan `responses` on completion of input chan `payloads`.
This enables the ability to do fee payer, and other approaches while staying concurrent
func Example() {
client := NewNodeClient()
sender := NewEd25519Account()
feePayer := NewEd25519Account()
payloads := make(chan TransactionBuildPayload)
responses := make(chan TransactionSubmissionResponse)
signingFunc := func(rawTxn RawTransactionImpl) (*SignedTransaction, error) {
switch rawTxn.(type) {
case *RawTransaction:
return nil, fmt.Errorf("only fee payer supported")
case *RawTransactionWithData:
rawTxnWithData := rawTxn.(*RawTransactionWithData)
switch rawTxnWithData.Variant {
case MultiAgentRawTransactionWithDataVariant:
return nil, fmt.Errorf("multi agent not supported, please provide a fee payer function")
case MultiAgentWithFeePayerRawTransactionWithDataVariant:
rawTxnWithData.Sign(sender)
txn, ok := rawTxnWithData.ToFeePayerTransaction()
default:
return nil, fmt.Errorf("unsupported rawTransactionWithData type")
}
default:
return nil, fmt.Errorf("unsupported rawTransactionImpl type")
}
}
// startup worker
go client.BuildSignAndSubmitTransactionsWithSignFunction(
sender,
payloads,
responses,
signingFunc
)
// Here add payloads, and wiating on resposnes
}
func (*NodeClient) BuildTransaction ¶
func (rc *NodeClient) BuildTransaction(sender AccountAddress, payload TransactionPayload, options ...any) (*RawTransaction, error)
BuildTransaction builds a raw transaction for signing for a single signer
For MultiAgent and FeePayer transactions use NodeClient.BuildTransactionMultiAgent
Accepts options:
func (*NodeClient) BuildTransactionMultiAgent ¶
func (rc *NodeClient) BuildTransactionMultiAgent(sender AccountAddress, payload TransactionPayload, options ...any) (*RawTransactionWithData, error)
BuildTransactionMultiAgent builds a raw transaction for signing with fee payer or multi-agent
For single signer transactions use NodeClient.BuildTransaction
Accepts options:
func (*NodeClient) BuildTransactions ¶
func (rc *NodeClient) BuildTransactions(sender AccountAddress, payloads chan TransactionBuildPayload, responses chan TransactionBuildResponse, setSequenceNumber chan uint64, options ...any)
BuildTransactions start a goroutine to process TransactionPayload and spit out RawTransactionImpl.
func (*NodeClient) EntryFunctionWithArgs ¶
func (rc *NodeClient) EntryFunctionWithArgs(moduleAddress AccountAddress, moduleName string, functionName string, typeArgs []any, args []any) (*EntryFunction, error)
EntryFunctionWithArgs generates an EntryFunction from on-chain Module ABI, and converts simple inputs to BCS encoded ones.
func (*NodeClient) EstimateGasPrice ¶
func (rc *NodeClient) EstimateGasPrice() (EstimateGasInfo, error)
EstimateGasPrice estimates the gas price given on-chain data TODO: add caching for some period of time
func (*NodeClient) EventsByHandle ¶
func (rc *NodeClient) EventsByHandle( account AccountAddress, eventHandle string, fieldName string, start *uint64, limit *uint64, ) ([]*api.Event, error)
EventsByHandle retrieves events by event handle and field name for a given account.
Arguments:
- account - The account address to get events for
- eventHandle - The event handle struct tag
- fieldName - The field in the event handle struct
- start - The starting sequence number. nil for most recent events
- limit - The number of events to return, 100 by default
func (*NodeClient) GetBCS ¶
func (rc *NodeClient) GetBCS(getUrl string) ([]byte, error)
GetBCS makes a GET request to the endpoint and parses the response into the given type with BCS
func (*NodeClient) GetChainId ¶
func (rc *NodeClient) GetChainId() (uint8, error)
GetChainId gets the chain ID of the network
func (*NodeClient) Info ¶
func (rc *NodeClient) Info() (NodeInfo, error)
Info gets general information about the blockchain
func (*NodeClient) NodeAPIHealthCheck ¶
func (rc *NodeClient) NodeAPIHealthCheck(durationSecs ...uint64) (api.HealthCheckResponse, error)
NodeAPIHealthCheck performs a health check on the node
Returns a HealthCheckResponse if successful, returns error if not.
func (*NodeClient) NodeHealthCheck
deprecated
func (rc *NodeClient) NodeHealthCheck(durationSecs ...uint64) (api.HealthCheckResponse, error)
NodeHealthCheck performs a health check on the node
Returns a HealthCheckResponse if successful, returns error if not.
Deprecated: Use NodeAPIHealthCheck instead
func (*NodeClient) PollForTransaction ¶
func (rc *NodeClient) PollForTransaction(hash string, options ...any) (*api.UserTransaction, error)
PollForTransaction waits up to 10 seconds for a transaction to be done, polling at 10Hz Accepts options PollPeriod and PollTimeout which should wrap time.Duration values. Not just a degenerate case of PollForTransactions, it may return additional information for the single transaction polled.
func (*NodeClient) PollForTransactions ¶
func (rc *NodeClient) PollForTransactions(txnHashes []string, options ...any) error
PollForTransactions waits up to 10 seconds for transactions to be done, polling at 10Hz Accepts options PollPeriod and PollTimeout which should wrap time.Duration values.
func (*NodeClient) RemoveHeader ¶
func (rc *NodeClient) RemoveHeader(key string)
RemoveHeader removes the header from being automatically set all future requests.
client.RemoveHeader("Authorization")
func (*NodeClient) SetHeader ¶
func (rc *NodeClient) SetHeader(key string, value string)
SetHeader sets the header for all future requests
client.SetHeader("Authorization", "Bearer abcde")
func (*NodeClient) SetTimeout ¶
func (rc *NodeClient) SetTimeout(timeout time.Duration)
SetTimeout adjusts the HTTP client timeout
client.SetTimeout(5 * time.Millisecond)
func (*NodeClient) SimulateTransaction ¶
func (rc *NodeClient) SimulateTransaction(rawTxn *RawTransaction, sender TransactionSigner, options ...any) ([]*api.UserTransaction, error)
SimulateTransaction simulates a transaction
func (*NodeClient) SimulateTransactionMultiAgent ¶
func (rc *NodeClient) SimulateTransactionMultiAgent(rawTxn *RawTransactionWithData, sender TransactionSigner, options ...any) ([]*api.UserTransaction, error)
SimulateTransactionMultiAgent simulates a transaction as fee payer or multi agent
func (*NodeClient) SubmitTransaction ¶
func (rc *NodeClient) SubmitTransaction(signedTxn *SignedTransaction) (*api.SubmitTransactionResponse, error)
SubmitTransaction submits a signed transaction to the network
func (*NodeClient) SubmitTransactions ¶
func (rc *NodeClient) SubmitTransactions(requests chan TransactionSubmissionRequest, responses chan TransactionSubmissionResponse)
SubmitTransactions consumes signed transactions, submits to aptos-node, yields responses. closes output chan `responses` when input chan `signedTxns` is closed.
func (*NodeClient) TransactionByHash ¶
func (rc *NodeClient) TransactionByHash(txnHash string) (*api.Transaction, error)
TransactionByHash gets info on a transaction The transaction may be pending or recently committed. If the transaction is a api.PendingTransaction, then it is still in the mempool. If the transaction is any other type, it has been committed.
data, err := c.TransactionByHash("0xabcd")
if err != nil {
if httpErr, ok := err.(aptos.HttpError) {
if httpErr.StatusCode == 404 {
// if we're sure this has been submitted, assume it is still pending elsewhere in the mempool
}
}
} else {
if data["type"] == "pending_transaction" {
// known to local mempool, but not committed yet
}
}
func (*NodeClient) TransactionByVersion ¶
func (rc *NodeClient) TransactionByVersion(version uint64) (*api.CommittedTransaction, error)
TransactionByVersion gets info on a transaction by version number The transaction will have been committed. The response will not be of the type api.PendingTransaction.
func (*NodeClient) Transactions ¶
func (rc *NodeClient) Transactions(start *uint64, limit *uint64) ([]*api.CommittedTransaction, error)
Transactions Get recent transactions.
Arguments:
- start is a version number. Nil for most recent transactions.
- limit is a number of transactions to return. 'about a hundred' by default.
func (*NodeClient) View ¶
func (rc *NodeClient) View(payload *ViewPayload, ledgerVersion ...uint64) ([]any, error)
View calls a view function on the blockchain and returns the return value of the function
func (*NodeClient) WaitForTransaction ¶
func (rc *NodeClient) WaitForTransaction(txnHash string, options ...any) (*api.UserTransaction, error)
WaitForTransaction does a long-GET for one transaction and wait for it to complete. Initially poll at 10 Hz for up to 1 second if node replies with 404 (wait for txn to propagate).
Optional arguments:
- PollPeriod: time.Duration, how often to poll for the transaction. Default 100ms.
- PollTimeout: time.Duration, how long to wait for the transaction. Default 10s.
func (*NodeClient) WaitTransactionByHash ¶
func (rc *NodeClient) WaitTransactionByHash(txnHash string) (*api.Transaction, error)
WaitTransactionByHash waits for a transaction to be confirmed by its hash. This function allows you to monitor the status of a transaction until it is finalized.
type NodeInfo ¶
type NodeInfo struct {
ChainId uint8 `json:"chain_id"` // ChainId is the chain ID of the network
EpochStr string `json:"epoch"` // EpochStr is the current epoch of the network. On Mainnet, this is usually every 2 hours.
LedgerTimestampStr string `json:"ledger_timestamp"` // LedgerTimestampStr is the timestamp the block was committed
LedgerVersionStr string `json:"ledger_version"` // LedgerVersionStr is the newest transaction available on the full node
OldestLedgerVersionStr string `json:"oldest_ledger_version"` // OldestLedgerVersionStr is the oldest ledger version not pruned on the full node
NodeRole string `json:"node_role"` // NodeRole is the role of the node in the network
BlockHeightStr string `json:"block_height"` // BlockHeightStr is the newest block available on the full node (by the time you call this there's already a new one!)
OldestBlockHeightStr string `json:"oldest_block_height"` // OldestBlockHeightStr is the oldest block note pruned on the full node
GitHash string `json:"git_hash"` // GitHash is the git hash of the node
}
NodeInfo information retrieved about the current state of the blockchain on API requests
func (NodeInfo) BlockHeight ¶
BlockHeight the newest block available on the full node (by the time you call this there's already a new one!)
func (NodeInfo) Epoch ¶
Epoch the current epoch of the network. On Mainnet, this is usually every 2 hours.
func (NodeInfo) LedgerTimestamp ¶
LedgerTimestamp is the timestamp the block was committed
func (NodeInfo) LedgerVersion ¶
LedgerVersion the newest transaction available on the full node
func (NodeInfo) OldestBlockHeight ¶
OldestBlockHeight the oldest block note pruned on the full node
func (NodeInfo) OldestLedgerVersion ¶
OldestLedgerVersion the oldest ledger version not pruned on the full node
type RawTransaction ¶
type RawTransaction struct {
Sender AccountAddress
SequenceNumber uint64
Payload TransactionPayload
MaxGasAmount uint64
GasUnitPrice uint64
// ExpirationTimestampSeconds is seconds since Unix epoch
ExpirationTimestampSeconds uint64
ChainId uint8
}
RawTransaction representation of a transaction's parts prior to signing Implements crypto.MessageSigner, crypto.Signer, bcs.Struct
func APTTransferTransaction ¶
func APTTransferTransaction(client *Client, sender TransactionSigner, dest AccountAddress, amount uint64, options ...any) (*RawTransaction, error)
APTTransferTransaction Move some APT from sender to dest, only for single signer Amount in Octas (10^-8 APT)
options may be: MaxGasAmount, GasUnitPrice, ExpirationSeconds, ValidUntil, SequenceNumber, ChainIdOption deprecated, please use the EntryFunction APIs
func (*RawTransaction) MarshalBCS ¶
func (txn *RawTransaction) MarshalBCS(ser *bcs.Serializer)
region RawTransaction bcs.Struct
func (*RawTransaction) Sign ¶
func (txn *RawTransaction) Sign(signer crypto.Signer) (*crypto.AccountAuthenticator, error)
region RawTransaction Signer
func (*RawTransaction) SignedTransaction ¶
func (txn *RawTransaction) SignedTransaction(sender crypto.Signer) (*SignedTransaction, error)
func (*RawTransaction) SignedTransactionWithAuthenticator ¶
func (txn *RawTransaction) SignedTransactionWithAuthenticator(auth *crypto.AccountAuthenticator) (*SignedTransaction, error)
SignedTransactionWithAuthenticator signs the sender only signed transaction
func (*RawTransaction) SigningMessage ¶
func (txn *RawTransaction) SigningMessage() ([]byte, error)
SigningMessage generates the bytes needed to be signed by a signer
func (*RawTransaction) UnmarshalBCS ¶
func (txn *RawTransaction) UnmarshalBCS(des *bcs.Deserializer)
type RawTransactionImpl ¶
type RawTransactionImpl interface {
bcs.Struct
// SigningMessage creates a raw signing message for the transaction
// Note that this should only be used externally if signing transactions outside the SDK. Otherwise, use Sign.
SigningMessage() (message []byte, err error)
// Sign signs a transaction and returns the associated AccountAuthenticator, it will underneath sign the SigningMessage
Sign(signer crypto.Signer) (*crypto.AccountAuthenticator, error)
}
type RawTransactionWithData ¶
type RawTransactionWithData struct {
Variant RawTransactionWithDataVariant
Inner RawTransactionWithDataImpl
}
func (*RawTransactionWithData) MarshalBCS ¶
func (txn *RawTransactionWithData) MarshalBCS(ser *bcs.Serializer)
region RawTransactionWithData bcs.Struct
func (*RawTransactionWithData) SetFeePayer ¶
func (txn *RawTransactionWithData) SetFeePayer( feePayer AccountAddress, ) bool
func (*RawTransactionWithData) Sign ¶
func (txn *RawTransactionWithData) Sign(signer crypto.Signer) (*crypto.AccountAuthenticator, error)
region RawTransactionWithData Signer
func (*RawTransactionWithData) SigningMessage ¶
func (txn *RawTransactionWithData) SigningMessage() ([]byte, error)
region RawTransactionWithData MessageSigner
func (*RawTransactionWithData) ToFeePayerSignedTransaction ¶
func (txn *RawTransactionWithData) ToFeePayerSignedTransaction( sender *crypto.AccountAuthenticator, feePayerAuthenticator *crypto.AccountAuthenticator, additionalSigners []crypto.AccountAuthenticator, ) (*SignedTransaction, bool)
func (*RawTransactionWithData) ToMultiAgentSignedTransaction ¶
func (txn *RawTransactionWithData) ToMultiAgentSignedTransaction( sender *crypto.AccountAuthenticator, additionalSigners []crypto.AccountAuthenticator, ) (*SignedTransaction, bool)
func (*RawTransactionWithData) UnmarshalBCS ¶
func (txn *RawTransactionWithData) UnmarshalBCS(des *bcs.Deserializer)
type RawTransactionWithDataVariant ¶
type RawTransactionWithDataVariant uint32
const ( MultiAgentRawTransactionWithDataVariant RawTransactionWithDataVariant = 0 MultiAgentWithFeePayerRawTransactionWithDataVariant RawTransactionWithDataVariant = 1 )
type ReferenceTag ¶
type ReferenceTag struct {
TypeParam TypeTag
}
ReferenceTag represents a reference of a type in Move
func (*ReferenceTag) GetType ¶
func (xt *ReferenceTag) GetType() TypeTagVariant
func (*ReferenceTag) MarshalBCS ¶
func (xt *ReferenceTag) MarshalBCS(_ *bcs.Serializer)
TODO: Do we need a proper serialization here
func (*ReferenceTag) String ¶
func (xt *ReferenceTag) String() string
region ReferenceTag TypeTagImpl
func (*ReferenceTag) UnmarshalBCS ¶
func (xt *ReferenceTag) UnmarshalBCS(_ *bcs.Deserializer)
type Script ¶
type Script struct {
Code []byte // The compiled script bytes
ArgTypes []TypeTag // The types of the arguments
Args []ScriptArgument // The arguments
}
Script A Move script as compiled code as a transaction
func (*Script) MarshalBCS ¶
func (s *Script) MarshalBCS(ser *bcs.Serializer)
region Script bcs.Struct
func (*Script) PayloadType ¶
func (s *Script) PayloadType() TransactionPayloadVariant
region Script TransactionPayloadImpl
func (*Script) UnmarshalBCS ¶
func (s *Script) UnmarshalBCS(des *bcs.Deserializer)
type ScriptArgument ¶
type ScriptArgument struct {
Variant ScriptArgumentVariant // The type of the argument
Value any // The value of the argument
}
ScriptArgument a Move script argument, which encodes its type with it
func (*ScriptArgument) MarshalBCS ¶
func (sa *ScriptArgument) MarshalBCS(ser *bcs.Serializer)
func (*ScriptArgument) UnmarshalBCS ¶
func (sa *ScriptArgument) UnmarshalBCS(des *bcs.Deserializer)
type ScriptArgumentVariant ¶
type ScriptArgumentVariant uint32
ScriptArgumentVariant the type of the script argument. If there isn't a value here, it is not supported.
Note that the only vector supported is vector<u8>
const ( ScriptArgumentU8 ScriptArgumentVariant = 0 // u8 type argument ScriptArgumentU64 ScriptArgumentVariant = 1 // u64 type argument ScriptArgumentU128 ScriptArgumentVariant = 2 // u128 type argument ScriptArgumentAddress ScriptArgumentVariant = 3 // address type argument ScriptArgumentU8Vector ScriptArgumentVariant = 4 // vector<u8> type argument ScriptArgumentBool ScriptArgumentVariant = 5 // bool type argument ScriptArgumentU16 ScriptArgumentVariant = 6 // u16 type argument ScriptArgumentU32 ScriptArgumentVariant = 7 // u32 type argument ScriptArgumentU256 ScriptArgumentVariant = 8 // u256 type argument ScriptArgumentSerialized ScriptArgumentVariant = 9 // Serialized type argument )
type SequenceNumber ¶
type SequenceNumber uint64
SequenceNumber will set the sequence number for a transaction
type SequenceNumberTracker ¶
func (*SequenceNumberTracker) Increment ¶
func (snt *SequenceNumberTracker) Increment() uint64
func (*SequenceNumberTracker) Update ¶
func (snt *SequenceNumberTracker) Update(next uint64) uint64
type SignedTransaction ¶
type SignedTransaction struct {
Transaction *RawTransaction // The transaction here is always a [RawTransaction], the rest of the information is in the authenticator
Authenticator *TransactionAuthenticator // The authenticator for a transaction (can't be be a standalone [crypto.AccountAuthenticator])
}
SignedTransaction a raw transaction plus its authenticator for a fully verifiable message
func (*SignedTransaction) Hash ¶
func (txn *SignedTransaction) Hash() (string, error)
Hash takes the hash of the SignedTransaction
Note: At the moment, this assumes that the transaction is a UserTransaction
func (*SignedTransaction) MarshalBCS ¶
func (txn *SignedTransaction) MarshalBCS(ser *bcs.Serializer)
region SignedTransaction bcs.Struct
func (*SignedTransaction) UnmarshalBCS ¶
func (txn *SignedTransaction) UnmarshalBCS(des *bcs.Deserializer)
func (*SignedTransaction) Verify ¶
func (txn *SignedTransaction) Verify() error
Verify checks a signed transaction's signature
type SignedTransactionVariant ¶
type SignedTransactionVariant uint8
SignedTransactionVariant is the variant for a signed transaction
const UserTransactionVariant SignedTransactionVariant = 0
UserTransactionVariant is the variant for a transaction submitted by a user. For now, we don't support any others, because they can't be submitted.
type SignerTag ¶
type SignerTag struct{}
SignerTag represents the signer type in Move
func (*SignerTag) GetType ¶
func (xt *SignerTag) GetType() TypeTagVariant
func (*SignerTag) MarshalBCS ¶
func (xt *SignerTag) MarshalBCS(_ *bcs.Serializer)
region SignerTag bcs.Struct
func (*SignerTag) UnmarshalBCS ¶
func (xt *SignerTag) UnmarshalBCS(_ *bcs.Deserializer)
type SingleSenderTransactionAuthenticator ¶
type SingleSenderTransactionAuthenticator struct {
Sender *crypto.AccountAuthenticator
}
region SingleSenderTransactionAuthenticator
func (*SingleSenderTransactionAuthenticator) MarshalBCS ¶
func (ea *SingleSenderTransactionAuthenticator) MarshalBCS(ser *bcs.Serializer)
region SingleSenderTransactionAuthenticator bcs.Struct
func (*SingleSenderTransactionAuthenticator) UnmarshalBCS ¶
func (ea *SingleSenderTransactionAuthenticator) UnmarshalBCS(des *bcs.Deserializer)
func (*SingleSenderTransactionAuthenticator) Verify ¶
func (ea *SingleSenderTransactionAuthenticator) Verify(msg []byte) bool
region SingleSenderTransactionAuthenticator TransactionAuthenticatorImpl
type StructTag ¶
type StructTag struct {
Address AccountAddress // Address is the address of the module
Module string // Module is the name of the module
Name string // Name is the name of the struct
TypeParams []TypeTag // TypeParams are the TypeTags of the type parameters
}
StructTag represents an on-chain struct of the form address::module::name<T1,T2,...> and each T is a TypeTag
func NewObjectTag ¶
func NewObjectTag(inner TypeTagImpl) *StructTag
NewObjectTag creates a 0x1::object::Object TypeTag based on an inner type
func NewOptionTag ¶
func NewOptionTag(inner TypeTagImpl) *StructTag
NewOptionTag creates a 0x1::option::Option TypeTag based on an inner type
func NewStringTag ¶
func NewStringTag() *StructTag
NewStringTag creates a TypeTag for 0x1::string::String
func (*StructTag) GetType ¶
func (xt *StructTag) GetType() TypeTagVariant
region StructTag TypeTagImpl
func (*StructTag) MarshalBCS ¶
func (xt *StructTag) MarshalBCS(ser *bcs.Serializer)
region StructTag bcs.Struct
func (*StructTag) String ¶
String outputs to the form address::module::name<type1, type2> e.g. 0x1::string::String or 0x42::my_mod::MultiType<u8,0x1::string::String>
func (*StructTag) UnmarshalBCS ¶
func (xt *StructTag) UnmarshalBCS(des *bcs.Deserializer)
type TransactionAuthenticator ¶
type TransactionAuthenticator struct {
Variant TransactionAuthenticatorVariant
Auth TransactionAuthenticatorImpl
}
TransactionAuthenticator is used for authorizing a transaction. This differs from crypto.AccountAuthenticator because it handles constructs like FeePayer and MultiAgent. Some keys can't stand on their own as TransactionAuthenticators. Implements TransactionAuthenticatorImpl, bcs.Struct
func NewTransactionAuthenticator ¶
func NewTransactionAuthenticator(auth *crypto.AccountAuthenticator) (*TransactionAuthenticator, error)
func (*TransactionAuthenticator) MarshalBCS ¶
func (ea *TransactionAuthenticator) MarshalBCS(ser *bcs.Serializer)
region TransactionAuthenticator bcs.Struct
func (*TransactionAuthenticator) UnmarshalBCS ¶
func (ea *TransactionAuthenticator) UnmarshalBCS(des *bcs.Deserializer)
func (*TransactionAuthenticator) Verify ¶
func (ea *TransactionAuthenticator) Verify(msg []byte) bool
region TransactionAuthenticator TransactionAuthenticatorImpl
type TransactionAuthenticatorVariant ¶
type TransactionAuthenticatorVariant uint8
region TransactionAuthenticator
const ( TransactionAuthenticatorEd25519 TransactionAuthenticatorVariant = 0 TransactionAuthenticatorMultiEd25519 TransactionAuthenticatorVariant = 1 TransactionAuthenticatorMultiAgent TransactionAuthenticatorVariant = 2 TransactionAuthenticatorFeePayer TransactionAuthenticatorVariant = 3 TransactionAuthenticatorSingleSender TransactionAuthenticatorVariant = 4 )
type TransactionBuildPayload ¶
type TransactionBuildPayload struct {
Id uint64
Type TransactionSubmissionType
Inner TransactionPayload // The actual transaction payload
Options []any // This is a placeholder to allow future optional arguments
}
type TransactionBuildResponse ¶
type TransactionBuildResponse struct {
Id uint64
Response RawTransactionImpl
Err error
}
type TransactionPayload ¶
type TransactionPayload struct {
Payload TransactionPayloadImpl
}
TransactionPayload the actual instructions of which functions to call on chain
func PublishPackagePayloadFromJsonFile ¶
func PublishPackagePayloadFromJsonFile(metadata []byte, bytecode [][]byte) (*TransactionPayload, error)
PublishPackagePayloadFromJsonFile publishes code created with the Aptos CLI to publish with it. The Aptos CLI can generate the associated file with the following CLI command:
aptos move build-publish-payload
metadata must be the BCS encoded metadata from the compiler, and bytecode must be the BCS encoded bytecode from the compiler. bytecode must be ordered in the same order out of the compiler, or it will fail on publishing.
func (*TransactionPayload) MarshalBCS ¶
func (txn *TransactionPayload) MarshalBCS(ser *bcs.Serializer)
region TransactionPayload bcs.Struct
func (*TransactionPayload) UnmarshalBCS ¶
func (txn *TransactionPayload) UnmarshalBCS(des *bcs.Deserializer)
type TransactionPayloadImpl ¶
type TransactionPayloadImpl interface {
bcs.Struct
PayloadType() TransactionPayloadVariant // This is specifically to ensure that wrong types don't end up here
}
type TransactionPayloadVariant ¶
type TransactionPayloadVariant uint32
region TransactionPayload
const ( TransactionPayloadVariantScript TransactionPayloadVariant = 0 TransactionPayloadVariantModuleBundle TransactionPayloadVariant = 1 // Deprecated TransactionPayloadVariantEntryFunction TransactionPayloadVariant = 2 TransactionPayloadVariantMultisig TransactionPayloadVariant = 3 )
type TransactionSigner ¶
type TransactionSigner interface {
crypto.Signer
// AccountAddress returns the address of the signer, this may differ from the AuthKey derived from the inner signer
AccountAddress() AccountAddress
}
TransactionSigner is a generic interface for a way to sign transactions. The default implementation is Account
Note that AccountAddress is needed to be the correct on-chain value for proper signing. This may differ from the AuthKey provided by the crypto.Signer
type TransactionSubmissionRequest ¶
type TransactionSubmissionRequest struct {
Id uint64
SignedTxn *SignedTransaction
}
type TransactionSubmissionResponse ¶
type TransactionSubmissionResponse struct {
Id uint64
Response *api.SubmitTransactionResponse
Err error
}
type TransactionSubmissionType ¶
type TransactionSubmissionType uint8
TransactionSubmissionType is the counter for an enum
const ( // TransactionSubmissionTypeSingle represents a single signer transaction, no multi-agent and no-fee payer TransactionSubmissionTypeSingle TransactionSubmissionType = iota // TransactionSubmissionTypeMultiAgent represents a multi-agent or fee payer transaction TransactionSubmissionTypeMultiAgent TransactionSubmissionType = iota )
type TypeTag ¶
type TypeTag struct {
Value TypeTagImpl
}
TypeTag is a wrapper around a TypeTagImpl e.g. BoolTag or U8Tag for the purpose of serialization and deserialization Implements:
func ConvertTypeTag ¶
func NewTypeTag ¶
func NewTypeTag(inner TypeTagImpl) TypeTag
NewTypeTag wraps a TypeTagImpl in a TypeTag
func ParseTypeTag ¶
func (*TypeTag) MarshalBCS ¶
func (tt *TypeTag) MarshalBCS(ser *bcs.Serializer)
MarshalBCS serializes the TypeTag to bytes
Implements:
func (*TypeTag) UnmarshalBCS ¶
func (tt *TypeTag) UnmarshalBCS(des *bcs.Deserializer)
UnmarshalBCS deserializes the TypeTag from bytes
Implements:
type TypeTagImpl ¶
type TypeTagImpl interface {
bcs.Struct
// GetType returns the TypeTagVariant for this [TypeTag]
GetType() TypeTagVariant
// String returns the canonical Move string representation of this [TypeTag]
String() string
}
TypeTagImpl is an interface describing all the different types of TypeTag. Unfortunately because of how serialization works, a wrapper TypeTag struct is needed to handle the differentiation between types
type TypeTagVariant ¶
type TypeTagVariant uint32
TypeTagVariant is an enum representing the different types of TypeTag
const ( TypeTagBool TypeTagVariant = 0 // Represents the bool type in Move BoolTag TypeTagU8 TypeTagVariant = 1 // Represents the u8 type in Move U8Tag TypeTagU64 TypeTagVariant = 2 // Represents the u64 type in Move U64Tag TypeTagU128 TypeTagVariant = 3 // Represents the u128 type in Move U128Tag TypeTagAddress TypeTagVariant = 4 // Represents the address type in Move AddressTag TypeTagSigner TypeTagVariant = 5 // Represents the signer type in Move SignerTag TypeTagVector TypeTagVariant = 6 // Represents the vector type in Move VectorTag TypeTagStruct TypeTagVariant = 7 // Represents the struct type in Move StructTag TypeTagU16 TypeTagVariant = 8 // Represents the u16 type in Move U16Tag TypeTagU32 TypeTagVariant = 9 // Represents the u32 type in Move U32Tag TypeTagU256 TypeTagVariant = 10 // Represents the u256 type in Move U256Tag TypeTagGeneric TypeTagVariant = 254 // Represents a generic type in Move GenericTag TypeTagReference TypeTagVariant = 255 // Represents the reference type in Move ReferenceTag )
type U8Tag ¶
type U8Tag struct{}
U8Tag represents the u8 type in Move
func (*U8Tag) GetType ¶
func (xt *U8Tag) GetType() TypeTagVariant
func (*U8Tag) UnmarshalBCS ¶
func (xt *U8Tag) UnmarshalBCS(_ *bcs.Deserializer)
type U16Tag ¶
type U16Tag struct{}
U16Tag represents the u16 type in Move
func (*U16Tag) GetType ¶
func (xt *U16Tag) GetType() TypeTagVariant
func (*U16Tag) MarshalBCS ¶
func (xt *U16Tag) MarshalBCS(_ *bcs.Serializer)
region U16Tag bcs.Struct
func (*U16Tag) UnmarshalBCS ¶
func (xt *U16Tag) UnmarshalBCS(_ *bcs.Deserializer)
type U32Tag ¶
type U32Tag struct{}
U32Tag represents the u32 type in Move
func (*U32Tag) GetType ¶
func (xt *U32Tag) GetType() TypeTagVariant
func (*U32Tag) MarshalBCS ¶
func (xt *U32Tag) MarshalBCS(_ *bcs.Serializer)
region U32Tag bcs.Struct
func (*U32Tag) UnmarshalBCS ¶
func (xt *U32Tag) UnmarshalBCS(_ *bcs.Deserializer)
type U64Tag ¶
type U64Tag struct{}
U64Tag represents the u64 type in Move
func (*U64Tag) GetType ¶
func (xt *U64Tag) GetType() TypeTagVariant
func (*U64Tag) MarshalBCS ¶
func (xt *U64Tag) MarshalBCS(_ *bcs.Serializer)
region U64Tag bcs.Struct
func (*U64Tag) UnmarshalBCS ¶
func (xt *U64Tag) UnmarshalBCS(_ *bcs.Deserializer)
type U128Tag ¶
type U128Tag struct{}
U128Tag represents the u128 type in Move
func (*U128Tag) GetType ¶
func (xt *U128Tag) GetType() TypeTagVariant
func (*U128Tag) MarshalBCS ¶
func (xt *U128Tag) MarshalBCS(_ *bcs.Serializer)
region U128Tag bcs.Struct
func (*U128Tag) UnmarshalBCS ¶
func (xt *U128Tag) UnmarshalBCS(_ *bcs.Deserializer)
type U256Tag ¶
type U256Tag struct{}
U256Tag represents the u256 type in Move
func (*U256Tag) GetType ¶
func (xt *U256Tag) GetType() TypeTagVariant
func (*U256Tag) MarshalBCS ¶
func (xt *U256Tag) MarshalBCS(_ *bcs.Serializer)
region U256Tag bcs.Struct
func (*U256Tag) UnmarshalBCS ¶
func (xt *U256Tag) UnmarshalBCS(_ *bcs.Deserializer)
type VectorTag ¶
type VectorTag struct {
TypeParam TypeTag // TypeParam is the type of the elements in the vector
}
VectorTag represents the vector<T> type in Move, where T is another TypeTag
func NewVectorTag ¶
func NewVectorTag(inner TypeTagImpl) *VectorTag
NewVectorTag creates a TypeTag for vector<inner>
func (*VectorTag) GetType ¶
func (xt *VectorTag) GetType() TypeTagVariant
region VectorTag TypeTagImpl
func (*VectorTag) MarshalBCS ¶
func (xt *VectorTag) MarshalBCS(ser *bcs.Serializer)
region TypeTagVector bcs.Struct
func (*VectorTag) UnmarshalBCS ¶
func (xt *VectorTag) UnmarshalBCS(des *bcs.Deserializer)
type ViewPayload ¶
type ViewPayload struct {
Module ModuleId // ModuleId of the View function e.g. 0x1::coin
Function string // Name of the View function e.g. balance
ArgTypes []TypeTag // TypeTags of the type arguments
Args [][]byte // Arguments to the function encoded in BCS
}
ViewPayload is a payload for a view function
func (*ViewPayload) MarshalBCS ¶
func (vp *ViewPayload) MarshalBCS(ser *bcs.Serializer)
type WorkerPoolConfig ¶
type WorkerPoolConfig struct {
NumWorkers uint32
// Channel buffer sizes. If 0, defaults to NumWorkers
BuildResponseBuffer uint32
SubmissionBuffer uint32
}
WorkerPoolConfig contains configuration for the transaction processing worker pool
Source Files
¶
- account.go
- accountInfo.go
- accountResourceInfo.go
- accountResourceRecord.go
- client.go
- client_util.go
- code.go
- coinPayloads.go
- commonPayloads.go
- doc.go
- estimateGasInfo.go
- faucet.go
- fungible_asset_client.go
- http.go
- indexerClient.go
- moduleId.go
- multisig.go
- nodeClient.go
- nodeInfo.go
- rawTransaction.go
- script.go
- signedTransaction.go
- transactionAuthenticator.go
- transactionPayload.go
- transactionSubmission.go
- typeConversion.go
- typetag.go
- util.go
- view.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api represents all types associated with the Aptos REST API.
|
Package api represents all types associated with the Aptos REST API. |
|
Package bcs implements Binary Canonical Serialization [BCS].
|
Package bcs implements Binary Canonical Serialization [BCS]. |
|
Package crypto handles all cryptographic types and operations associated with Aptos.
|
Package crypto handles all cryptographic types and operations associated with Aptos. |
|
Package examples is a collection of examples for the Aptos Go SDK.
|
Package examples is a collection of examples for the Aptos Go SDK. |
|
alternative_signing
command
alternative_signing is an example of how to create an alternative signer for the SDK, if you prefer a different library
|
alternative_signing is an example of how to create an alternative signer for the SDK, if you prefer a different library |
|
external_signing
command
external_signing is an example of how to create an external signer for the SDK, if you have something like cold storage signing
|
external_signing is an example of how to create an external signer for the SDK, if you have something like cold storage signing |
|
fungible_asset
command
fungible_asset is an example of how to create and transfer fungible assets
|
fungible_asset is an example of how to create and transfer fungible assets |
|
local_abi
command
transfer_coin is an example of how to make a coin transfer transaction in the simplest possible way
|
transfer_coin is an example of how to make a coin transfer transaction in the simplest possible way |
|
multi_agent
command
transfer_coin is an example of how to make a coin transfer transaction in the simplest possible way
|
transfer_coin is an example of how to make a coin transfer transaction in the simplest possible way |
|
offchain_multisig
command
transfer_coin is an example of how to make a coin transfer transaction in the simplest possible way
|
transfer_coin is an example of how to make a coin transfer transaction in the simplest possible way |
|
onchain_multisig
command
onchain_multisig is an example of how to create a multisig account and perform transactions with it.
|
onchain_multisig is an example of how to create a multisig account and perform transactions with it. |
|
performance_transaction
command
performance_transaction shows how to improve performance of the transaction submission of a single transaction
|
performance_transaction shows how to improve performance of the transaction submission of a single transaction |
|
remote_abi
command
transfer_coin is an example of how to make a coin transfer transaction in the simplest possible way
|
transfer_coin is an example of how to make a coin transfer transaction in the simplest possible way |
|
script_args_transaction
command
|
|
|
script_transaction
command
fungible_asset is an example of how to create and transfer fungible assets
|
fungible_asset is an example of how to create and transfer fungible assets |
|
sending_concurrent_transactions
command
sending_concurrent_transactions shows how to submit transactions serially or concurrently on a single account
|
sending_concurrent_transactions shows how to submit transactions serially or concurrently on a single account |
|
sponsored_transaction
command
sponsored_transaction is an example of how to make a sponsored transaction in Aptos.
|
sponsored_transaction is an example of how to make a sponsored transaction in Aptos. |
|
transfer_coin
command
transfer_coin is an example of how to make a coin transfer transaction in the simplest possible way
|
transfer_coin is an example of how to make a coin transfer transaction in the simplest possible way |
|
internal
|
|
|
types
Package types is an internal package that contains the types used in the Aptos Go SDK.
|
Package types is an internal package that contains the types used in the Aptos Go SDK. |