Optional
settings: AptosConfigReadonly
accountReadonly
ansReadonly
coinReadonly
configReadonly
digitalReadonly
eventReadonly
faucetReadonly
fungibleReadonly
generalReadonly
keylessReadonly
objectReadonly
stakingReadonly
tableReadonly
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
const transaction = await aptos.addDigitalAssetPropertyTransaction({
creator: alice,
propertyKey: "newKey",
propertyType: "BOOLEAN",
propertyValue: true,
digitalAssetAddress: "0x123",
});
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
const transaction = await aptos.addDigitalAssetTypedPropertyTransaction({
creator: alice,
propertyKey: "typedKey",
propertyType: "STRING",
propertyValue: "hello",
digitalAssetAddress: "0x123",
});
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
const transaction = await aptos.burnDigitalAssetTransaction({
creator: alice,
digitalAssetAddress: "0x123",
});
Creates a new collection within the specified account
A SimpleTransaction that when submitted will create the collection.
const transaction = await aptos.createCollectionTransaction({
creator: alice,
description: "collectionDescription",
name: "collectionName",
uri: "collection-uri.com",
});
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
const account = await aptos.deriveAccountFromPrivateKey({privateKey:new Ed25519PrivateKey("0x123")})
Derives the Keyless Account from the JWT token and corresponding EphemeralKeyPair. It will lookup the pepper from the pepper service if not explicitly provided. It will compute the proof via the proving service. It will ch
the EphemeralKeyPair used to generate the nonce in the JWT token
JWT token
Optional
pepper?: HexInputthe pepper
Optional
proofa callback function that if set, the fetch of the proof will be done in the background. Once fetching finishes the callback function will be called. This should be used to provide a more responsive user experience as now they are not blocked on fetching the proof. Thus the function will return much more quickly.
Optional
uida key in the JWT token to use to set the uidVal in the IdCommitment
A KeylessAccount that can be used to sign transactions
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
const transaction = await aptos.freezeDigitalAssetTransaferTransaction({
creator: alice,
digitalAssetAddress: "0x123",
});
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
const transaction = await aptos.fundAccount({accountAddress:"0x123", amount: 100})
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
const accountAPTAmount = await aptos.getAccountAPTAmount({accountAddress:"0x123"})
Queries the account's coin amount by the coin type
The account address we want to get the total count for
Optional
coinThe coin type to query
Optional
faThe fungible asset metadata address to query. Note: coinType will automatically fill this in if not provided when migrated to fungible assets
Optional
minimumOptional ledger version to sync up to, before querying
Current amount of account's coin
const accountCoinAmount = await aptos.getAccountCoinAmount({accountAddress:"0x123", coinType:"0x1::aptos_coin::AptosCoin"})
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
const accountCoinsCount = await aptos.getAccountCoinsCount({accountAddress:"0x123"})
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
const accountCoinsData = await aptos.getAccountCoinsData({accountAddress:"0x123"})
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
const accountCollectionsWithOwnedTokens = await aptos.getAccountCollectionsWithOwnedTokens({accountAddress:"0x123"})
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
const events = await aptos.getAccountEventsByCreationNumber({accountAddress:"0x123",creationNumber: 0})
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
const events = await aptos.getAccountEventsByEventType({accountAddress:"0x123",eventType: "0x1::transaction_fee::FeeStatement"})
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
const module = await aptos.getAccountModule({accountAddress:"0x456"}) // An example of an account module response
{
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
const accountOwnedObjects = await aptos.getAccountOwnedObjects({accountAddress:"0x123"})
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
const accountOwnedTokens = await aptos.getAccountOwnedTokens({accountAddress:"0x456"})
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
const accountOwnedTokens = await aptos.getAccountOwnedTokensFromCollectionAddress({accountAddress:"0x123", collectionAddress:"0x456"})
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
const resource = await aptos.getAccountResource({accountAddress:"0x456"})
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
const resources = await aptos.getAccountResources({accountAddress:"0x456"})
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
const tokensCount = await aptos.getAccountTokensCount({accountAddress:"0x456"})
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
const transactions = await aptos.getAccountTransactions({accountAddress:"0x456"})
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
const accountTransactionsCount = await aptos.getAccountTransactionsCount({accountAddress:"0x123"})
Queries top user transactions
The number of transactions to return
GetChainTopUserTransactionsResponse
const topUserTransactions = await aptos.getChainTopUserTransactions({limit:5})
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
use getCollectionDataByCreatorAddressAndCollectionName - this function will be removed in the next major release
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
const collection = await aptos.getCollectionData({creatorAddress:"0x123",collectionName:"myCollection"})
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
Optional
options?: TokenStandardArg & PaginationArgsGetCollectionDataResponse response type
const collection = await aptos.getCollectionDataByCollectionId({collectionId:"0x123"})
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 address of the collection's creator
Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: TokenStandardArg & PaginationArgsGetCollectionDataResponse response type
const collection = await aptos.getCollectionDataByCreatorAddressAnd({creatorAddress:"0x123"})
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?: TokenStandardArg & PaginationArgsGetCollectionDataResponse response type
const collection = await aptos.getCollectionDataByCreatorAddressAndCollectionName({
creatorAddress:"0x123",
collectionName:"myCollection"
})
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
const collection = await aptos.getCollectionId({creatorAddress:"0x123",collectionName:"myCollection"})
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.
const digitalAssetOwner = await aptos.getCurrentDigitalAssetOwnership({digitalAssetAddress:"0x123"})
Queries all fungible asset balances
Optional
args: { Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & WhereArg<CurrentFungibleAssetBalancesBoolExp>Optional configuration for pagination and filtering
A list of fungible asset metadata
const fungibleAssetBalances = await aptos.getCurrentFungibleAssetBalances()
Queries delegated staking activities
Delegator address
Optional
minimumOptional ledger version to sync up to, before querying
Pool address
GetDelegatedStakingActivitiesResponse response type
const delegators = await aptos.getDelegatedStakingActivities({delegatorAddress:"0x123",poolAddress:"0x456"})
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.
const digitalAssetActivity = await aptos.getDigitalAssetActivity({digitalAssetAddress:"0x123"})
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.
const digitalAsset = await aptos.getDigitalAssetData({digitalAssetAddress:"0x123"})
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
const events = await aptos.getEvents()
// with filtering
const events = await aptos.getEvents({options: { where: { account_address: { _eq: "0x123" } } }});
Retrieve the expiration time of a domain name or subdomain name from the contract.
A string of the name to retrieve
number as a unix timestamp in milliseconds.
// 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
Queries all fungible asset activities
Optional
args: { Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & WhereArg<FungibleAssetActivitiesBoolExp>Optional configuration for pagination and filtering
A list of fungible asset metadata
const fungibleAssetActivities = await aptos.getFungibleAssetActivities()
Queries all fungible asset metadata.
Optional
args: { Optional
minimumOptional ledger version to sync up to, before querying
Optional
options?: PaginationArgs & WhereArg<FungibleAssetMetadataBoolExp>Optional configuration for pagination and filtering
A list of fungible asset metadata
const fungibleAsset = await aptos.getFungibleAssetMetadata()
Queries a fungible asset metadata by the asset type
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
const fungibleAsset = await aptos.getFungibleAssetMetadataByAssetType({assetType:"0x123::test_coin::TestCoin"})
Queries a fungible asset metadata by the creator address
This query returns the fungible asset metadata for a specific fungible asset.
The creator address of the fungible asset.
Optional
minimumOptional ledger version to sync up to, before querying
A fungible asset metadata item
const fungibleAsset = await aptos.getFungibleAssetMetadataByCreatorAddress({creatorAddress:"0x123"})
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
const gasPrice = await aptos.waitForTransaction()
Queries for the Aptos ledger info
Aptos Ledger Info
const ledgerInfo = await aptos.getLedgerInfo() // an example of the returned data
{
"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
const events = await aptos.getModuleEventsByEventType({eventType:"0x1::transaction_fee::FeeStatement"})
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
const delegators = await aptos.getNumberOfDelegators({poolAddress:"0x123"})
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
const delegators = await aptos.getNumberOfDelegatorsForAllPools()
Fetch the object data based on the oabject address
Optional
minimumThe object address
Optional
options?: PaginationArgs & OrderByArg<{ Configuration options for waitForTransaction
The object data
const object = await aptos.getObjectDataByObjectAddress({objectAddress:"0x123"})
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.
const digitalAssets = await aptos.getOwnedDigitalAssets({ownerAddress:"0x123"})
Retrieve the owner address of a domain name or subdomain name from the contract.
A string of the name to retrieve
AccountAddress if the name is owned, undefined otherwise
// Will return the owner address of "test.aptos.apt" or undefined
const owner = await aptos.getOwnerAddress({name: "test.aptos"})
// owner = 0x123...
Fetches the pepper from the Aptos pepper service API.
Optional
derivationa derivation path used for creating multiple accounts per user via the BIP-44 standard. Defaults to "m/44'/637'/0'/0'/0".
the EphemeralKeyPair used to generate the nonce in the JWT token
JWT token
The pepper which is a Uint8Array of length 31.
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.
A AccountAddressInput (address) of the account
a string if the account has a primary name, undefined otherwise
const name = await aptos.getPrimaryName({address: alice.accountAddress})
// name = test.aptos
Query the processor status for a specific processor type.
The processor type to query
const status = await aptos.getProcessorStatus({processorType:"account_transactions_processor"})
Fetches a proof from the Aptos prover service API.
the EphemeralKeyPair used to generate the nonce in the JWT token
JWT token
Optional
pepper?: HexInputthe pepper used for the account. If not provided it will be fetched from the Aptos pepper service
Optional
uida key in the JWT token to use to set the uidVal in the IdCommitment
The proof which is represented by a ZeroKnowledgeSig.
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
const transaction = await aptos.transaction.build.simple({...})
const message = await aptos.getSigningMessage({transaction})
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.
Note, this query calls the fullnode server
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
const tableItem = await aptos.getTableItem({
handle: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca",
data: {
key_type: "address", // Move type of table key
value_type: "u128", // Move type of table value
key: "0x619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935" // Value of table key
},
})
Queries for a table items data.
Optional options.where
param can be passed to filter the response.
Note, this query calls the indexer server
Optional
minimumOptional
options?: PaginationArgs & WhereArg<TableItemsBoolExp> & OrderByArg<{ GetTableItemsDataResponse
const data = await aptos.getTableItemsData({
options: { where: {
table_handle: { _eq: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca" },
transaction_version: { _eq: "0" }
}
},
});
Queries for a table items metadata.
Optional options.where
param can be passed to filter the response.
Note, this query calls the indexer server
Optional
minimumOptional
options?: PaginationArgs & WhereArg<TableMetadatasBoolExp> & OrderByArg<{ GetTableItemsMetadataResponse
const data = await aptos.getTableItemsMetadata({
options: { where: { handle: { _eq: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca" } } },
});
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
A string of the name: primary, primary.apt, secondary.primary, secondary.primary.apt, etc.
AccountAddress if the name has a target, undefined otherwise
const targetAddr = await aptos.getTargetAddress({name: "test.aptos"})
// targetAddr = 0x123...
Queries on-chain transaction by transaction hash. This function will return pending transactions.
Transaction from mempool (pending) or on-chain (committed) transaction
const transaction = await aptos.getTransactionByHash({transactionHash:"0x123"})
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.
const transaction = await aptos.getTransactions({ledgerVersion:1})
Queries on-chain transactions. This function will not return pending
transactions. For that, use getTransactionsByHash
.
Optional
args: { Optional
options?: PaginationArgsArray of on-chain transactions
const transactions = await aptos.getTransactions()
Defines if specified transaction is currently in pending state
To create a transaction hash:
true
if transaction is in pending state and false
otherwise
const isPendingTransaction = await aptos.isPendingTransaction({transactionHash:"0x123"})
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
const accountAddress = await aptos.lookupOriginalAccountAddress({authenticationKey:account.accountAddress})
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
const transaction = await aptos.mintDigitalAssetTransaction({
creator: alice,
description: "collectionDescription",
collection: "collectionName",
name: "digitalAssetName",
uri: "digital-asset-uri.com",
});
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
const transaction = await aptos.mintSoulBoundTransaction({
account: alice,
collection: "collectionName",
description: "collectionDescription",
name: "digitalAssetName",
uri: "digital-asset-uri.com",
recipient: "0x123"
});
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
const transaction = await aptos.publishPackageTransaction({
account: alice,
metadataBytes,
moduleBytecode: [byteCode],
})
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
const topUserTransactions = await aptos.queryIndexer({
query: `query MyQuery {
ledger_infos {
chain_id
}}`;
})
Registers a new name
SimpleTransaction
// 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,
},
});
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
const transaction = await aptos.removeDigitalAssetPropertyTransaction({
creator: alice,
propertyKey: "newKey",
propertyType: "BOOLEAN",
propertyValue: true,
digitalAssetAddress: "0x123",
});
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.
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
await aptos.renewDomain({sender: alice, name: "test"})
// test.apt will be renewed for one year
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
const response = await aptos.rotateAuthKey({
fromAccount: alice,
toNewPrivateKey: new ED25519PublicKey("0x123"),
})
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
const transaction = await aptos.setDigitalAssetDescriptionTransaction({
creator: alice,
description: "digitalAssetDescription",
digitalAssetAddress: "0x123",
});
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
const transaction = await aptos.setDigitalAssetNameTransaction({
creator: alice,
name: "digitalAssetName",
digitalAssetAddress: "0x123",
});
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
const transaction = await aptos.setDigitalAssetURITransaction({
creator: alice,
uri: "digital-asset-uri.com",
digitalAssetAddress: "0x123",
});
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.
Optional
name?: stringA string of the name: test, test.apt, test.aptos, test.aptos.apt, etc.
Optional
options?: InputGenerateTransactionOptionsThe sender account
SimpleTransaction
await aptos.setPrimaryName({sender: alice, name: "test.aptos"})
const primaryName = await aptos.getPrimaryName({address: alice.accountAddress})
// primaryName = test.aptos
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
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
await aptos.setTargetAddress({sender: alice, name: "test.aptos", address: bob.accountAddress})
const address = await aptos.getTargetAddress({name: "test.aptos"})
// address = bob.accountAddress
Sign a transaction that can later be submitted to chain
The signer account
A raw transaction to sign on
AccountAuthenticator
const transaction = await aptos.transaction.build.simple({...})
const transaction = await aptos.transaction.sign({
signer: alice,
transaction
})
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
PendingTransactionResponse
const transaction = await aptos.transaction.build.simple({...})
const transaction = await aptos.signAndSubmitTransaction({
signer: alice,
transaction
})
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
const transaction = await aptos.transaction.build.simple({...})
const transaction = await aptos.transaction.signAsFeePayer({
signer: alice,
transaction
})
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
const transferCoinTransaction = await aptos.transferCoinTransaction({
sender: "0x123",
recipient:"0x456",
amount: 10,
})
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
const transaction = await aptos.transferDigitalAssetTransaction({
sender: alice,
digitalAssetAddress: "0x123",
recipient: "0x456",
});
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.
const transaction = await aptos.transferFungibleAsset({
sender: alice,
fungibleAssetMetadataAddress: "0x123",
recipient: "0x456",
amount: 5
})
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
const transaction = await aptos.unfreezeDigitalAssetTransaferTransaction({
creator: alice,
digitalAssetAddress: "0x123",
});
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
const transaction = await aptos.updateDigitalAssetPropertyTransaction({
creator: alice,
propertyKey: "newKey",
propertyType: "BOOLEAN",
propertyValue: false,
digitalAssetAddress: "0x123",
});
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
const transaction = await aptos.updateDigitalAssetTypedPropertyTransaction({
creator: alice,
propertyKey: "typedKey",
propertyType: "U8",
propertyValue: 2,
digitalAssetAddress: "0x123",
});
Queries for a Move view function
Optional
options?: LedgerVersionArgPayload for the view function
an array of Move values
const data = await aptos.view({
payload: {
function: "0x1::coin::balance",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
functionArguments: [accountAddress],
}
})
Queries for a Move view function with JSON, this provides compatability with the old aptos
package
Optional
options?: LedgerVersionArgPayload for the view function
an array of Move values
const data = await aptos.view({
payload: {
function: "0x1::coin::balance",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
functionArguments: [accountAddress.toString()],
}
})
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.
const transaction = await aptos.waitForTransaction({transactionHash:"0x123"})
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.
Example