Optional
settings: AptosConfigReadonly
accountReadonly
ansReadonly
coinReadonly
configReadonly
digitalReadonly
eventReadonly
faucetReadonly
fungibleReadonly
generalReadonly
stakingReadonly
transactionAdd a digital asset property
The digital asset address
Optional
digitalOptional
options?: InputGenerateTransactionOptionsThe property key for storing on-chain properties
The type of property value
The property value to be stored on-chain
A SimpleTransaction that can be simulated or submitted to chain
Add a typed digital asset property
The digital asset address
Optional
digitalOptional
options?: InputGenerateTransactionOptionsThe property key for storing on-chain properties
The type of property value
The property value to be stored on-chain
A SimpleTransaction that can be simulated or submitted to chain
An array of transaction payloads
Optional
options?: Omit<InputGenerateTransactionOptions, "accountSequenceNumber">optional. Transaction generation configurations (excluding accountSequenceNumber)
The sender account to sign and submit the transaction
void. Throws if any error
Prefer to use aptos.transaction.batch.forSingleAccount()
Batch transactions for a single account.
This function uses a transaction worker that receives payloads to be processed and submitted to chain. Note that this process is best for submitting multiple transactions that dont rely on each other, i.e batch funds, batch token mints, etc.
If any worker failure, the functions throws an error.
Burn a digital asset by its creator
The creator account
The digital asset address
Optional
digitalOptional
options?: InputGenerateTransactionOptionsA SimpleTransaction that can be simulated or submitted to chain
Creates a new collection within the specified account
A SimpleTransaction that when submitted will create the collection.
Derives an account by providing a private key. This functions resolves the provided private key type and derives the public key from it.
If the privateKey is a Secp256k1 type, it derives the account using the derived public key and auth key using the SingleKey scheme locally.
If the privateKey is a ED25519 type, it looks up the authentication key on chain, and uses it to resolve whether it is a Legacy ED25519 key or a Unified ED25519 key. It then derives the account based on that.
An account private key
Account type
Freeze digital asset transfer ability
The creator account
The digital asset address
Optional
digitalOptional
options?: InputGenerateTransactionOptionsA SimpleTransaction that can be simulated or submitted to chain
This creates an account if it does not exist and mints the specified amount of coins into that account
Address of the account to fund
Amount of tokens to fund the account with
Optional
options?: WaitForTransactionOptionsConfiguration options for waitForTransaction
Transaction hash of the transaction that funded the account
Queries the account's APT amount
The account address we want to get the total count for
Optional
minimumOptional ledger version to sync up to, before querying
Current amount of account's APT
Queries the account's coin amount by the coin type
The account address we want to get the total count for
The coin type to query
Optional
minimumOptional ledger version to sync up to, before querying
Current amount of account's coin
Queries the current count of an account's coins aggregated
The account address we want to get the total count for
Optional
minimumOptional ledger version to sync up to, before querying
Current count of the aggregated count of all account's coins
Queries an account's coins data
The account address we want to get the coins data for
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & OrderByArg<{ Array with the coins data
Queries for all collections that an account currently has tokens for.
This query returns all tokens (v1 and v2 standards) an account owns, including NFTs, fungible, soulbound, etc. If you want to get only the token from a specific standard, you can pass an optional tokenStandard param
The account address we want to get the collections for
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: TokenStandardArg & PaginationArgs & OrderByArg<{ Collections array with the collections data
Fetches all top level domain names for an account
a promise of an array of ANSName
Get events by creation number and an account address
The account address
The event creation number
Optional
minimumOptional ledger version to sync up to, before querying
Promise
Get events by event type and an account address
The account address
The event type
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & OrderByArg<{ Promise
Queries the current state for an Aptos account given its account address
Aptos account address
The account data
{
sequence_number: "1",
authentication_key: "0x5307b5f4bc67829097a8ba9b43dba3b88261eeccd1f709d9bde240fc100fbb69"
}
Queries for a specific account module given account address and module name
Aptos account address
The name of the module
Optional
options?: LedgerVersionArgAccount module
{
bytecode: "0xa11ceb0b0600000006010002030206050807070f0d081c200",
abi: { address: "0x1" }
}
Queries for all modules in an account given an account address
Note: In order to get all account modules, this function may call the API multiple times as it auto paginates.
Aptos account address
Optional
options?: PaginationArgs & LedgerVersionArgAccount modules
Fetches all names for an account (both top level domains and subdomains)
a promise of an array of ANSName
Queries an account's owned objects
The account address we want to get the objects for
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & OrderByArg<{ Objects array with the object data
Queries the account's current owned tokens.
This query returns all tokens (v1 and v2 standards) an account owns, including NFTs, fungible, soulbound, etc. If you want to get only the token from a specific standard, you can pass an optional tokenStandard param
The account address we want to get the tokens for
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: TokenStandardArg & PaginationArgs & OrderByArg<{ Tokens array with the token data
Queries all current tokens of a specific collection that an account owns by the collection address
This query returns all tokens (v1 and v2 standards) an account owns, including NFTs, fungible, soulbound, etc. If you want to get only the token from a specific standard, you can pass an optional tokenStandard param
The account address we want to get the tokens for
The address of the collection being queried
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: TokenStandardArg & PaginationArgs & OrderByArg<{ Tokens array with the token data
Queries a specific account resource given account address and resource type. Note that the default is any
in order
to allow for ease of accessing properties of the object.
Aptos account address
Optional
options?: LedgerVersionArgString representation of an on-chain Move struct type, i.e "0x1::aptos_coin::AptosCoin"
Account resource
{
value: 6
}
Queries all account resources given an account address
Note: In order to get all account resources, this function may call the API multiple times as it auto paginates.
Aptos account address
Optional
options?: PaginationArgs & LedgerVersionArgAccount resources
Fetches all subdomains names for an account
a promise of an array of ANSName
Queries the current count of tokens owned by an account
The account address
Optional
minimumOptional ledger version to sync up to, before querying
Current count of tokens owned by the account
Queries account transactions given an account address
Note: In order to get all account transactions, this function may call the API multiple times as it auto paginates.
Aptos account address
Optional
options?: PaginationArgsThe account transactions
Queries the current count of transactions submitted by an account
The account address we want to get the total count for
Optional
minimumOptional ledger version to sync up to, before querying
Current count of transactions made by an account
Queries data of a specific collection by the collection creator address and the collection name.
If, for some reason, a creator account has 2 collections with the same name in v1 and v2,
can pass an optional tokenStandard
parameter to query a specific standard
the name of the collection
the address of the collection's creator
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: TokenStandardArgGetCollectionDataResponse response type
Queries data of a specific collection by the collection ID.
the ID of the collection, it's the same thing as the address of the collection object
Optional
minimumOptional ledger version to sync up to, before querying
GetCollectionDataResponse response type
Queries a collection's ID.
This is the same as the collection's object address in V2, but V1 does not use objects, and does not have an address
the name of the collection
the address of the collection's creator
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: TokenStandardArgthe collection id
Gets digital asset ownership data given the address of a digital asset.
Optional
minimumOptional ledger version to sync up to, before querying
GetCurrentTokenOwnershipResponse containing relevant ownership data of the digital asset.
Queries all fungible asset balances
Optional
args: { Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & WhereArg<CurrentFungibleAssetBalancesBoolExp>A list of fungible asset metadata
Queries delegated staking activities
Delegator address
Optional
minimumOptional ledger version to sync up to, before querying
Pool address
GetDelegatedStakingActivitiesResponse response type
Gets the activity data given the address of a digital asset.
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & OrderByArg<{ GetTokenActivityResponse containing relevant activity data to the digital asset.
Gets digital asset data given the address of a digital asset.
Optional
minimumOptional ledger version to sync up to, before querying
GetTokenDataResponse containing relevant data to the digital asset.
Fetches all subdomains names for a given domain. Note, this will not return the domain itself.
a promise of an array of ANSName
Get all events
An optional where
can be passed in to filter out the response.
Optional
args: { Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & OrderByArg<{ GetEventsQuery response type
{ where:
{
transaction_version: { _eq: 123456 },
}
}
Retrieve the expiration time of a domain name or subdomain name from the contract.
// Will return the expiration of "test.aptos.apt" or undefined
const exp = await aptos.getExpiration({name: "test.aptos"})
// new Date(exp) would give you the date in question: 2021-01-01T00:00:00.000Z
A string of the name to retrieve
number as a unix timestamp in milliseconds.
Queries all fungible asset activities
Optional
args: { Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & WhereArg<FungibleAssetActivitiesBoolExp>A list of fungible asset metadata
Queries all fungible asset metadata.
Optional
args: { Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & WhereArg<FungibleAssetMetadataBoolExp>A list of fungible asset metadata
Queries a fungible asset metadata
This query returns the fungible asset metadata for a specific fungible asset.
The asset type of the fungible asset. e.g "0x1::aptos_coin::AptosCoin" for Aptos Coin "0xc2948283c2ce03aafbb294821de7ee684b06116bb378ab614fa2de07a99355a8" - address format if this is fungible asset
Optional
minimumOptional ledger version to sync up to, before querying
A fungible asset metadata item
Gives an estimate of the gas unit price required to get a transaction on chain in a reasonable amount of time. For more information https://api.mainnet.aptoslabs.com/v1/spec#/operations/estimate_gas_price
Object holding the outputs of the estimate gas API
{
gas_estimate: number;
deprioritized_gas_estimate?: number;
prioritized_gas_estimate?: number;
}
Queries for the Aptos ledger info
Aptos Ledger Info
{
"chain_id": 4,
"epoch": "8",
"ledger_version": "714",
"oldest_ledger_version": "0",
"ledger_timestamp": "1694695496521775",
"node_role": "validator",
"oldest_block_height": "0",
"block_height": "359",
"git_hash": "c82193f36f4e185fed9f68c4ad21f6c6dd390c6e"
}
Get module events by event type
The event type
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & OrderByArg<{ Promise
Fetches a single name from the indexer
A string of the name to retrieve, e.g. "test.aptos.apt" or "test.apt" or "test". Can be inclusive or exclusive of the .apt suffix. Can be a subdomain.
A promise of an ANSName or undefined
Queries current number of delegators in a pool. Throws an error if the pool is not found.
Optional
minimumOptional ledger version to sync up to, before querying
Pool address
The number of delegators for the given pool
Queries current number of delegators in a pool. Throws an error if the pool is not found.
Optional
args: { Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: OrderByArg<{ GetNumberOfDelegatorsForAllPoolsResponse response type
Gets the digital assets that the given address owns.
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & OrderByArg<{ The address of the owner
GetOwnedTokensResponse containing ownership data of the digital assets belonging to the ownerAddresss.
Retrieve the owner address of a domain name or subdomain name from the contract.
// Will return the owner address of "test.aptos.apt" or undefined
const owner = await aptos.getOwnerAddress({name: "test.aptos"})
// owner = 0x123...
A string of the name to retrieve
AccountAddress if the name is owned, undefined otherwise
Retrieve the primary name for an account. An account can have multiple names that target it, but only a single name that is primary. An account also may not have a primary name.
const name = await aptos.getPrimaryName({address: alice.accountAddress})
// name = test.aptos
A AccountAddressInput (address) of the account
a string if the account has a primary name, undefined otherwise
Query the processor status for a specific processor type.
The processor type to query
Returns a signing message for a transaction.
This allows a user to sign a transaction using their own preferred signing method, and then submit it to the network.
A raw transaction for signing elsewhere
Queries for 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.
Object that describes table item
A pointer to where that table is stored
Optional
options?: LedgerVersionArgTable item value rendered in JSON
https://api.devnet.aptoslabs.com/v1/accounts/0x1/resource/0x1::coin::CoinInfo%3C0x1::aptos_coin::AptosCoin%3E
{
data.key_type = "address" // Move type of table key
data.value_type = "u128" // Move type of table value
data.key = "0x619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935" // Value of table key
}
Retrieve the target address of a domain or subdomain name. This is the address the name points to for use on chain. Note, the target address can point to addresses that are not the owner of the name
const targetAddr = await aptos.getTargetAddress({name: "test.aptos"})
// targetAddr = 0x123...
A string of the name: primary, primary.apt, secondary.primary, secondary.primary.apt, etc.
AccountAddress if the name has a target, undefined otherwise
Queries on-chain transaction by transaction hash. This function will return pending transactions.
Transaction from mempool (pending) or on-chain (committed) transaction
Queries on-chain transaction by version. This function will not return pending transactions.
On-chain transaction. Only on-chain transactions have versions, so this function cannot be used to query pending transactions.
Queries on-chain transactions. This function will not return pending
transactions. For that, use getTransactionsByHash
.
Optional
args: { Optional
options?: PaginationArgsArray of on-chain transactions
Defines if specified transaction is currently in pending state
To create a transaction hash:
true
if transaction is in pending state and false
otherwise
Looks up the account address for a given authentication key
This handles both if the account's authentication key has been rotated or not.
The authentication key
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: LedgerVersionArgPromise
Create a transaction to mint a digital asset into the creators account within an existing collection.
the name of the collection the digital asset belongs to
the creator of the collection
the description of the digital asset
the name of the digital asset
Optional
options?: InputGenerateTransactionOptionsOptional
propertyOptional
propertyOptional
propertythe URI to additional info about the digital asset
A SimpleTransaction that can be simulated or submitted to chain
Mint a soul bound digital asset into a recipient's account
The account that mints the digital asset
The collection name that the digital asset belongs to
The digital asset description
The digital asset name
Optional
options?: InputGenerateTransactionOptionsOptional
propertyThe property keys for storing on-chain properties
Optional
propertyThe type of property values
Optional
propertyThe property values to be stored on-chain
The account address where the digital asset will be created
The digital asset URL
A SimpleTransaction that can be simulated or submitted to chain
Generates a transaction to publish a move package to chain.
To get the metadataBytes
and byteCode
, can compile using Aptos CLI with command
aptos move compile --save-metadata ...
,
For more info https://aptos.dev/tutorials/your-first-dapp/#step-4-publish-a-move-module
The publisher account
The package metadata bytes
An array of the bytecode of each module in the package in compiler output order
Optional
options?: InputGenerateTransactionOptionsA SimpleTransaction that can be simulated or submitted to chain
A generic function for retrieving data from Aptos Indexer. For more detailed queries specification see https://cloud.hasura.io/public/graphiql?endpoint=https://api.mainnet.aptoslabs.com/v1/graphql
The provided T type
{
query: `query MyQuery {
ledger_infos {
chain_id
}
}`;
}
Registers a new name
// An example of registering a subdomain name assuming def.apt is already registered
// and belongs to the sender alice.
const txn = aptos.registerName({
sender: alice,
name: "test.aptos.apt",
expiration: {
policy: "subdomain:independent",
expirationDate: Date.now() + 30 * 24 * 60 * 60 * 1000,
},
});
SimpleTransaction
Remove a digital asset property
The digital asset address
Optional
digitalOptional
options?: InputGenerateTransactionOptionsThe property key for storing on-chain properties
The type of property value
The property value to be stored on-chain
A SimpleTransaction that can be simulated or submitted to chain
Renews a domain name
Note: If a domain name was minted with V1 of the contract, it will automatically be upgraded to V2 via this transaction.
await aptos.renewDomain({sender: alice, name: "test"})
// test.apt will be renewed for one year
A string of the domain the subdomain will be under. The signer must be the domain owner. Subdomains cannot be renewed.
Optional
options?: InputGenerateTransactionOptionsThe sender account
Optional
years?: 1The number of years to renew the name. Currently only one year is permitted.
SimpleTransaction
Rotate an account's auth key. After rotation, only the new private key can be used to sign txns for the account. Note: Only legacy Ed25519 scheme is supported for now. More info: https://aptos.dev/guides/account-management/key-rotation/
The account to rotate the auth key for
The new private key to rotate to
PendingTransactionResponse
Set the digital asset description
The creator account
The digital asset description
The digital asset address
Optional
digitalOptional
options?: InputGenerateTransactionOptionsA SimpleTransaction that can be simulated or submitted to chain
Set the digital asset name
The creator account
The digital asset address
Optional
digitalThe digital asset name
Optional
options?: InputGenerateTransactionOptionsA SimpleTransaction that can be simulated or submitted to chain
Set the digital asset name
The creator account
The digital asset address
Optional
digitalOptional
options?: InputGenerateTransactionOptionsThe digital asset uri
A SimpleTransaction that can be simulated or submitted to chain
Sets the primary name for the sender. An account can have multiple names that target it, but only a single name that is primary. An account also may not have a primary name.
await aptos.setPrimaryName({sender: alice, name: "test.aptos"})
const primaryName = await aptos.getPrimaryName({address: alice.accountAddress})
// primaryName = test.aptos
Optional
name?: stringA string of the name: test, test.apt, test.aptos, test.aptos.apt, etc.
Optional
options?: InputGenerateTransactionOptionsThe sender account
SimpleTransaction
Sets the target address of a domain or subdomain name. This is the address the name points to for use on chain. Note, the target address can point to addresses that are not the owner of the name
await aptos.setTargetAddress({sender: alice, name: "test.aptos", address: bob.accountAddress})
const address = await aptos.getTargetAddress({name: "test.aptos"})
// address = bob.accountAddress
A AccountAddressInput of the address to set the domain or subdomain to
A string of the name: test.aptos.apt, test.apt, test, test.aptos, etc.
Optional
options?: InputGenerateTransactionOptionsSimpleTransaction
Sign a transaction that can later be submitted to chain
The signer account
A raw transaction to sign on
AccountAuthenticator
Sign and submit a single signer transaction to chain
The signer account to sign the transaction
An instance of a RawTransaction, plus optional secondary/fee payer addresses
{
rawTransaction: RawTransaction,
secondarySignerAddresses? : Array<AccountAddress>,
feePayerAddress?: AccountAddress
}
PendingTransactionResponse
Sign a transaction as a fee payer that can later be submitted to chain
The fee payer signer account
A raw transaction to sign on
AccountAuthenticator
Generate a transfer coin transaction that can be simulated and/or signed and submitted
The amount to transfer
Optional
coinoptional. The coin struct type to transfer. Defaults to 0x1::aptos_coin::AptosCoin
Optional
options?: InputGenerateTransactionOptionsThe recipient address
The sender account
SimpleTransaction
Transfer a digital asset (non fungible digital asset) ownership.
We can transfer a digital asset only when the digital asset is not frozen (i.e. owner transfer is not disabled such as for soul bound digital assets)
The digital asset address
Optional
digitaloptional. The digital asset type, default to "0x4::token::Token"
Optional
options?: InputGenerateTransactionOptionsThe recipient account address
The sender account of the current digital asset owner
A SimpleTransaction that can be simulated or submitted to chain
Transfer amount
of fungible asset from sender's primary store to recipient's primary store.
Use this method to transfer any fungible asset including fungible token.
Optional
options?: InputGenerateTransactionOptionsA SimpleTransaction that can be simulated or submitted to chain.
Unfreeze digital asset transfer ability
The creator account
The digital asset address
Optional
digitalOptional
options?: InputGenerateTransactionOptionsA SimpleTransaction that can be simulated or submitted to chain
Update a digital asset property
The digital asset address
Optional
digitalOptional
options?: InputGenerateTransactionOptionsThe property key for storing on-chain properties
The type of property value
The property value to be stored on-chain
A SimpleTransaction that can be simulated or submitted to chain
Update a typed digital asset property
The digital asset address
Optional
digitalOptional
options?: InputGenerateTransactionOptionsThe property key for storing on-chain properties
The type of property value
The property value to be stored on-chain
A SimpleTransaction that can be simulated or submitted to chain
Queries for a Move view function
Optional
options?: LedgerVersionArgPayload for the view function
an array of Move values
`
const payload: ViewRequest = {
function: "0x1::coin::balance",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
functionArguments: [accountAddress],
};
`
Waits for a transaction to move past the pending state.
There are 4 cases.
checkSuccess
is true, the function will throw a FailedTransactionError
If checkSuccess
is false, the function will resolve with the transaction response where the success
field is false.args.options.timeoutSecs
seconds.Optional
options?: WaitForTransactionOptionsThe hash of a transaction previously submitted to the blockchain.
The transaction on-chain. See above for more details.
Generated using TypeDoc
This class is the main entry point into Aptos's APIs and separates functionality into different namespaces.
To use the SDK, create a new Aptos instance to get access to all the sdk functionality.