Establishes a connection to Aptos node
A url of the Aptos Node API endpoint
A faucet url
Optional
config: Partial<OpenAPIConfig>An optional config for inner axios instance Detailed config description: https://github.com/axios/axios#request-config
Readonly
nodeThis creates an account if it does not exist and mints the specified amount of coins into that account
Hashes of submitted transactions
Hex-encoded 16 bytes Aptos account address wich mints tokens
Amount of tokens to mint
Generates a raw transaction out of a transaction payload
A raw transaction object
Optional
extraArgs: OptionalTransactionArgsHelper for generating, signing, and submitting a transaction.
The transaction response from the API.
AptosAccount of transaction sender.
Transaction payload.
Optional
extraArgs: OptionalTransactionArgsExtra args for building the transaction payload.
Helper for generating, submitting, and waiting for a transaction, and then
checking whether it was committed successfully. Under the hood this is just
generateSignSubmitTransaction
and then waitForTransactionWithResult
, see
those for information about the return / error semantics of this function.
Optional
extraArgs: OptionalTransactionArgs & { Generates an entry function transaction request that can be submitted to produce a raw transaction that can be signed, which upon being signed can be submitted to the blockchain This function fetches the remote ABI and uses it to serialized the data, therefore users don't need to handle serialization by themselves.
A raw transaction object
Hex-encoded 32 byte Aptos account address of transaction sender
Entry function transaction payload type
Optional
options: Partial<SubmitTransactionRequest>Options allow to overwrite default transaction options.
Queries an Aptos account by address
Core account resource, used for identifying account and transaction execution
An example of the returned account
{
sequence_number: "1",
authentication_key: "0x5307b5f4bc67829097a8ba9b43dba3b88261eeccd1f709d9bde240fc100fbb69"
}
Hex-encoded 32 byte Aptos account address
Queries module associated with given account by module name
Note: In order to get all account resources, this function may call the API multiple times as it paginates.
Specified module.
Module is represented by MoveModule interface. It contains module bytecode
and abi
,
which JSON representation of a module
Hex-encoded 32 byte Aptos account address
The name of the module
Optional
query: { Optional
ledgerSpecifies ledger version of transactions. By default latest version will be used
Queries modules associated with given account
Note: In order to get all account modules, this function may call the API multiple times as it paginates.
Account modules array for a specific ledger version.
Module is represented by MoveModule interface. It contains module bytecode
and abi
,
which is JSON representation of a module
Hex-encoded 32 byte Aptos account address
Optional
query: { Optional
ledgerSpecifies ledger version of transactions. By default latest version will be used
Queries resource associated with given account by resource type
Account resource of specified type and ledger version
An example of an account resource
{
type: "0x1::aptos_coin::AptosCoin",
data: { value: 6 }
}
Hex-encoded 32 byte Aptos account address
String representation of an on-chain Move struct type
Optional
query: { Optional
ledgerSpecifies ledger version of transactions. By default latest version will be used
Queries all resources associated with given account
Account resources for a specific ledger version
Hex-encoded 32 byte Aptos account address
Optional
query: { Optional
ledgerSpecifies ledger version of transactions. By default latest version will be used
Queries transactions sent by given account
An array of on-chain transactions, sent by account
Hex-encoded 32 byte Aptos account address
Optional
query: PaginationArgsOptional pagination object
Get block by block transaction version
Block
Ledger version to lookup block information for
Optional
withTransactions: booleanIf set to true, include all transactions in the block
Event types are globally identifiable by an account address
and
monotonically increasing creation_number
, one per event type emitted
to the given account. This API returns events corresponding to that
that event type.
Array of events assotiated with the given account and creation number.
Hex-encoded 32 byte Aptos account, with or without a 0x
prefix,
for which events are queried. This refers to the account that events were emitted
to, not the account hosting the move module that emits that event type.
Creation number corresponding to the event type.
Optional
query: PaginationArgsThis API uses the given account address
, eventHandle
, and fieldName
to build a key that can globally identify an event types. It then uses this
key to return events emitted to the given account matching that event type.
Array of events
Hex-encoded 32 byte Aptos account, with or without a 0x
prefix,
for which events are queried. This refers to the account that events were emitted
to, not the account hosting the move module that emits that event type.
String representation of an on-chain Move struct type.
(e.g. 0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>
)
The field name of the EventHandle in the struct
Optional
query: PaginationArgsOptional query object
Queries the latest ledger information
Latest ledger information
Example of returned data
{
chain_id: 15,
epoch: 6,
ledgerVersion: "2235883",
ledger_timestamp:"1654580922321826"
}
Gets a table item for a table identified by the handle and the key for the item. Key and value types need to be passed in to help with key serialization and value deserialization.
Table item value rendered in JSON
A pointer to where that table is stored
Object, that describes table item
Optional
query: { Optional
ledgerTransaction from mempool (pending) or on-chain (committed) transaction
Transaction hash should be hex-encoded bytes string with 0x prefix.
On-chain transaction. Only on-chain transactions have versions, so this function cannot be used to query pending transactions.
Transaction version is an uint64 number.
Queries on-chain transactions. This function will not return pending
transactions. For that, use getTransactionsByHash
.
Array of on-chain transactions
Optional
query: PaginationArgsOptional pagination object
Lookup the original address by the current derived address
original address
Publishes a move package. packageMetadata
and modules
can be generated with command
aptos move compile --save-metadata [ --included-artifacts=<...> ]
.
Transaction hash
package metadata bytes
bytecodes of modules
Optional
extraArgs: OptionalTransactionArgsRotate an account's auth key. After rotation, only the new private key can be used to sign txns for the account. WARNING: You must create a new instance of AptosAccount after using this function.
PendingTransaction
Account of which the auth key will be rotated
New private key
Optional
extraArgs: OptionalTransactionArgsExtra args for building the transaction payload.
Helper for signing and submitting a transaction.
The transaction response from the API.
AptosAccount of transaction sender.
A generated Raw transaction payload.
Converts a transaction request produced by generateTransaction
into a properly
signed transaction, which can then be submitted to the blockchain
A transaction, signed with sender account
AptosAccount of transaction sender
A raw transaction generated by generateTransaction
method
Generates and submits a transaction to the transaction simulation endpoint. For this we generate a transaction with a fake signature.
The BCS encoded signed transaction, which you should then provide
The sender or sender's public key. When private key is available, AptosAccount
instance
can be used to send the transaction for simulation. If private key is not available, sender's public key can be
used to send the transaction for simulation.
The raw transaction to be simulated, likely created
by calling the generateTransaction
function.
Optional
query: { Optional
estimateIf set to true, the gas unit price in the transaction will be ignored and the estimated value will be used.
Optional
estimateIf set to true, the max gas value in the transaction will be ignored and the maximum possible gas will be used.
If set to true, the transaction will use a higher price than the original estimate.
Submits the BCS serialization of a signed transaction to the simulation endpoint.
Simulation result in the form of UserTransaction.
The output of generateBCSSimulation
.
Optional
query: { Optional
estimateOptional
estimateOptional
estimateSubmits a signed transaction to the endpoint that takes BCS payload
Transaction that is accepted and submitted to mempool
A BCS transaction representation
Submits a signed transaction to the transaction endpoint.
Transaction that is accepted and submitted to mempool
A transaction, signed by signTransaction
method
Defines if specified transaction is currently in pending state
true
if transaction is in pending state and false
otherwise
A hash of transaction
To create a transaction hash:
Call for a move view function
MoveValue[]
Transaction payload
Optional
ledger_version: stringThis function works the same as waitForTransactionWithResult
except it
doesn't return the transaction in those cases, it returns nothing. For
more information, see the documentation for waitForTransactionWithResult
.
Optional
extraArgs: { Optional
checkOptional
timeoutWait for a transaction to move past pending state.
There are 4 possible outcomes:
In case 1, this function resolves with the transaction response returned by the API.
In case 2, the function will throw an ApiError, likely with an HTTP status code indicating some problem with the request (e.g. 400).
In case 3, if checkSuccess
is false (the default), this function returns
the transaction response just like in case 1, in which the success
field
will be false. If checkSuccess
is true, it will instead throw a
FailedTransactionError.
In case 4, this function throws a WaitForTransactionError.
See above.
const rawTransaction = await this.generateRawTransaction(sender.address(), payload, extraArgs);
const bcsTxn = AptosClient.generateBCSTransaction(sender, rawTransaction);
const pendingTransaction = await this.submitSignedBCSTransaction(bcsTxn);
const transasction = await this.aptosClient.waitForTransactionWithResult(pendingTransaction.hash);
The hash of a transaction previously submitted to the blockchain.
Optional
extraArgs: { Optional
checkSee above. Defaults to false.
Optional
timeoutTimeout in seconds. Defaults to 20 seconds.
Static
generateBCSSimulationNote: Unless you have a specific reason for using this, it'll probably be simpler
to use simulateTransaction
.
Generates a BCS transaction that can be submitted to the chain for simulation.
The BCS encoded signed transaction, which you should then pass into
the submitBCSSimulation
function.
The account that will be used to send the transaction for simulation.
The raw transaction to be simulated, likely created by calling
the generateTransaction
function.
Static
generateBCSTransactionGenerates a signed transaction that can be submitted to the chain for execution.
Generated using TypeDoc
Class for requsting tokens from faucet