Optional
settings: AptosConfigConfiguration settings for the Aptos client.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
async function runExample() {
// Create a new Aptos client with default settings
const config = new AptosConfig({ network: Network.TESTNET }); // Specify your own settings if needed
const aptos = new Aptos(config);
console.log("Aptos client initialized:", aptos);
}
runExample().catch(console.error);
Readonly
accountReadonly
ansReadonly
coinReadonly
configReadonly
digitalReadonly
eventReadonly
faucetReadonly
fungibleReadonly
generalReadonly
keylessReadonly
objectReadonly
stakingReadonly
tableReadonly
transactionAdd a digital asset property to the blockchain. This function allows you to specify a new property for a digital asset, including its key, type, and value.
The arguments for adding a digital asset property.
The account that mints the digital asset.
The digital asset address.
Optional
digitalAssetType?: `${string}::${string}::${string}`(Optional) The type of the digital asset.
Optional
options?: InputGenerateTransactionOptions(Optional) Options for generating the transaction.
The 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 the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Add a digital asset property
const transaction = await aptos.addDigitalAssetPropertyTransaction({
creator: Account.generate(), // Replace with a real account
propertyKey: "newKey",
propertyType: "BOOLEAN",
propertyValue: true,
digitalAssetAddress: "0x123", // Replace with a real digital asset address
});
console.log(transaction);
}
runExample().catch(console.error);
Add a typed digital asset property to the blockchain. This function allows you to define and store a specific property for a digital asset, enabling better categorization and management of digital assets.
The parameters for adding the typed property.
The account that mints the digital asset.
The digital asset address.
Optional
digitalAssetType?: `${string}::${string}::${string}`The optional type of the digital asset.
Optional
options?: InputGenerateTransactionOptionsOptional transaction generation options.
The 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 the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Adding a typed digital asset property
const transaction = await aptos.addDigitalAssetTypedPropertyTransaction({
creator: Account.generate(), // replace with a real account
propertyKey: "typedKey",
propertyType: "STRING",
propertyValue: "hello",
digitalAssetAddress: "0x123", // replace with a real digital asset address
});
console.log(transaction);
}
runExample().catch(console.error);
The arguments for batching transactions.
An array of transaction payloads to be processed.
Optional
options?: Omit<InputGenerateTransactionOptions, "accountSequenceNumber">Optional. Transaction generation configurations (excluding accountSequenceNumber).
The sender account to sign and submit the transactions.
Prefer to use aptos.transaction.batch.forSingleAccount()
Batch transactions for a single account by submitting multiple transaction payloads. This function is useful for efficiently processing and submitting transactions that do not depend on each other, such as batch funding or batch token minting.
import { Aptos, AptosConfig, Network, Account } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
const sender = Account.generate(); // Generate a new account for sending transactions
async function runExample() {
const transactions = [
{ }, // Build your first transaction payload
{ }, // Build your second transaction payload
];
// Batch transactions for the single account
await aptos.batchTransactionsForSingleAccount({
sender,
data: transactions,
});
console.log("Batch transactions submitted successfully.");
}
runExample().catch(console.error);
Burn a digital asset by its creator, allowing for the removal of a specified digital asset from the blockchain.
The arguments for burning the digital asset.
The creator account that is burning the digital asset.
The address of the digital asset to be burned.
Optional
digitalAssetType?: `${string}::${string}::${string}`Optional. The type of the digital asset being burned.
Optional
options?: InputGenerateTransactionOptionsOptional. Additional options for generating the transaction.
A SimpleTransaction that can be simulated or submitted to the chain.
import { Aptos, AptosConfig, Network, Account } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
const creator = Account.generate(); // Replace with a real creator account
const transaction = await aptos.burnDigitalAssetTransaction({
creator: creator,
digitalAssetAddress: "0x123", // Replace with a real digital asset address
});
console.log(transaction);
}
runExample().catch(console.error);
Creates a new collection within the specified account.
The account of the collection's creator.
The description of the collection.
The name of the collection.
Optional
options?: InputGenerateTransactionOptionsOptional parameters for generating the transaction.
The parameters below are optional:
The URI to additional info about the collection.
The account of the collection's creator.
The description of the collection.
The name of the collection.
The URI to additional info about the collection.
Optional parameters for generating the transaction.
The parameters below are optional:
Controls the max supply of the digital assets. Defaults to MAX_U64_BIG_INT.
Controls mutability of the collection's description. Defaults to true.
Controls mutability of the collection's royalty. Defaults to true.
Controls mutability of the collection's URI. Defaults to true.
Controls mutability of the digital asset's description. Defaults to true.
Controls mutability of the digital asset's name. Defaults to true.
Controls mutability of digital asset's properties. Defaults to true.
Controls mutability of the digital asset's URI. Defaults to true.
Controls whether digital assets can be burnable by the creator. Defaults to true.
Controls whether digital assets can be frozen by the creator. Defaults to true.
The numerator of the royalty to be paid to the creator when a digital asset is transferred. Defaults to 0.
The denominator of the royalty to be paid to the creator when a digital asset is transferred. Defaults to 1.
A SimpleTransaction that when submitted will create the collection.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Creating a new collection transaction
const transaction = await aptos.createCollectionTransaction({
creator: Account.generate(), // Replace with a real account
description: "A unique collection of digital assets.",
name: "My Digital Collection",
uri: "https://mycollection.com",
});
console.log("Transaction created:", transaction);
}
runExample().catch(console.error);
Derives an account by providing a private key. This function 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 an ED25519 type, it looks up the authentication key on chain to determine whether it is a Legacy ED25519 key or a Unified ED25519 key, and then derives the account based on that.
The derived Account type.
import { Aptos, AptosConfig, Network, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Deriving an account from a private key
const account = await aptos.deriveAccountFromPrivateKey({
privateKey: new Ed25519PrivateKey("0x123") // replace with a real private key
});
console.log(account);
}
runExample().catch(console.error);
Freeze the ability to transfer a specified digital asset. This function allows the creator to restrict the transfer capability of a digital asset.
The arguments for freezing the digital asset transfer.
The creator account initiating the freeze.
The address of the digital asset to be frozen.
Optional
digitalAssetType?: `${string}::${string}::${string}`Optional. The type of the digital asset being frozen.
Optional
options?: InputGenerateTransactionOptionsOptional. Additional options for generating the transaction.
A SimpleTransaction that can be simulated or submitted to the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Freeze the digital asset transfer
const transaction = await aptos.freezeDigitalAssetTransaferTransaction({
creator: Account.generate(), // Replace with a real account if needed
digitalAssetAddress: "0x123", // Replace with a real digital asset address
});
console.log(transaction);
}
runExample().catch(console.error);
This function creates an account if it does not exist and mints the specified amount of coins into that account.
The arguments for funding the account.
Transaction hash of the transaction that funded the account.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fund an account with a specified amount of tokens
const transaction = await aptos.fundAccount({
accountAddress: "0x1", // replace with your account address
amount: 100,
});
console.log("Transaction hash:", transaction.hash);
}
runExample().catch(console.error);
Retrieves the current amount of APT for a specified account.
The arguments for the account query.
The current amount of APT for the specified account.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get the APT amount for a specific account
const accountAPTAmount = await aptos.getAccountAPTAmount({ accountAddress: "0x1" }); // replace with a real account address
console.log("Account APT Amount:", accountAPTAmount);
}
runExample().catch(console.error);
Queries the current amount of a specified coin held by an account.
The parameters for querying the account's coin amount.
The account address to query for the coin amount.
Optional
coinType?: `${string}::${string}::${string}`The coin type to query. Note: If not provided, it may be automatically populated if faMetadataAddress
is specified.
Optional
faMetadataAddress?: AccountAddressInputThe fungible asset metadata address to query. Note: If not provided, it may be automatically
populated if coinType
is specified.
Optional
minimumLedgerVersion?: AnyNumberNot used anymore, here for backward compatibility see https://github.com/aptos-labs/aptos-ts-sdk/pull/519, will be removed in the near future. Optional ledger version to sync up to before querying.
The current amount of the specified coin held by the account.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Query the account's coin amount for a specific coin type
const accountCoinAmount = await aptos.getAccountCoinAmount({
accountAddress: "0x1", // replace with a real account address
coinType: "0x1::aptos_coin::AptosCoin" // specify the coin type
});
console.log(`Account coin amount: ${accountCoinAmount}`);
}
runExample().catch(console.error);
Retrieves the current count of an account's coins aggregated across all types.
The parameters for the account coins count query.
The current count of the aggregated coins for the specified account.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Getting the account coins count for a specific account
const accountCoinsCount = await aptos.getAccountCoinsCount({ accountAddress: "0x1" }); // replace with a real account address
console.log("Account Coins Count:", accountCoinsCount);
}
runExample().catch(console.error);
Retrieves the coins data for a specified account.
The account address for which to retrieve the coin's data.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: PaginationArgs & OrderByArg<An array containing the coins data for the specified account.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching coins data for a specific account
const accountCoinsData = await aptos.getAccountCoinsData({
accountAddress: "0x1", // replace with a real account address
options: {
limit: 10, // specify the number of results to return
orderBy: { asset_type: "asc" }, // specify the order of results
},
});
console.log(accountCoinsData);
}
runExample().catch(console.error);
Queries for all collections that an account currently has tokens for, including NFTs, fungible tokens, and soulbound tokens. If you want to filter by a specific token standard, you can pass an optional tokenStandard parameter.
The account address we want to get the collections for.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: TokenStandardArg & PaginationArgs & OrderByArg<Collections array with the collections data.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get account collections with owned tokens for a specific account
const accountCollectionsWithOwnedTokens = await aptos.getAccountCollectionsWithOwnedTokens({
accountAddress: "0x1", // replace with a real account address
options: {
tokenStandard: "NFT", // specify the token standard if needed
limit: 10, // specify the number of results to return
},
});
console.log(accountCollectionsWithOwnedTokens);
}
runExample().catch(console.error);
Fetches all top-level domain names for a specified account.
The arguments for retrieving account domains.
An AccountAddressInput of the address to retrieve domain names for.
Optional, the offset to start from when fetching names.
Optional, a number of the names to fetch per request.
The order to sort the names by.
Additional filters to apply to the query.
A promise of an array of ANSName.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching all top-level domain names for a specific account
const domains = await aptos.getAccountDomains({
accountAddress: "0x1", // replace with a real account address
options: {
limit: 10, // specify the number of names to fetch
offset: 0, // specify the offset for pagination
orderBy: "created_at", // specify the order by which to sort the names
where: {
// additional filters can be specified here
},
},
});
console.log(domains);
}
runExample().catch(console.error);
Retrieve events associated with a specific account address and creation number.
The parameters for retrieving account events.
Promise
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get events for the account at creation number 0
const events = await aptos.getAccountEventsByCreationNumber({
accountAddress: "0x1", // replace with a real account address
creationNumber: 0,
});
console.log(events);
}
runExample().catch(console.error);
Retrieve events associated with a specific account address and event type.
The account address to query events for.
The type of event to filter by.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: PaginationArgs & OrderByArg<Optional pagination and ordering parameters for the event query.
Promise
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get events for a specific account and event type
const events = await aptos.getAccountEventsByEventType({
accountAddress: "0x1", // replace with a real account address
eventType: "0x1::transaction_fee::FeeStatement", // replace with a real event type
minimumLedgerVersion: 1, // optional, specify if needed
});
console.log(events);
}
runExample().catch(console.error);
Queries the current state for an Aptos account given its account address.
The account data.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve account information for a specific address
const accountInfo = await aptos.getAccountInfo({ accountAddress: "0x1" }); // replace with a real account address
console.log(accountInfo);
}
runExample().catch(console.error);
Queries for a specific account module given an account address and module name.
The account module associated with the specified account address and module name.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get the account module for a specific account address and module name
const module = await aptos.getAccountModule({
accountAddress: "0x1", // replace with a real account address
moduleName: "MyModule" // specify the module name
});
console.log(module);
}
runExample().catch(console.error);
Queries for all modules in an account given an account address. This function may call the API multiple times to auto paginate through results.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching account modules for a specific account
const accountModules = await aptos.getAccountModules({
accountAddress: "0x1", // replace with a real account address
options: {
offset: 0, // starting from the first module
limit: 10, // limiting to 10 modules
},
});
console.log(accountModules);
}
runExample().catch(console.error);
Fetches all names for an account, including both top-level domains and subdomains.
The arguments for fetching account names.
An AccountAddressInput of the address to retrieve names for.
Optional parameters for fetching names.
Optional, the offset to start from when fetching names.
Optional, a number of the names to fetch per request.
The order to sort the names by.
Additional filters to apply to the query.
A promise of an array of ANSName.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetch account names for a specific address
const accountNames = await aptos.getAccountNames({
accountAddress: "0x1", // replace with a real account address
options: {
limit: 10, // specify how many names to fetch
orderBy: "name", // specify the order by which to sort the names
},
});
console.log(accountNames);
}
runExample().catch(console.error);
Queries an account's owned objects.
The account address we want to get the objects for.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: PaginationArgs & OrderByArg<Objects array with the object data.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get the objects owned by the specified account
const accountOwnedObjects = await aptos.getAccountOwnedObjects({
accountAddress: "0x1", // replace with a real account address
minimumLedgerVersion: 1, // optional, specify if needed
options: {
offset: 0, // optional, specify if needed
limit: 10, // optional, specify if needed
orderBy: "created_at", // optional, specify if needed
},
});
console.log(accountOwnedObjects);
}
runExample().catch(console.error);
Queries the tokens currently owned by a specified account, including NFTs and fungible tokens. If desired, you can filter the results by a specific token standard.
The account address for which to retrieve owned tokens.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: TokenStandardArg & PaginationArgs & OrderByArg<An array of tokens with their respective data.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get the tokens owned by a specific account
const accountOwnedTokens = await aptos.getAccountOwnedTokens({
accountAddress: "0x1", // replace with a real account address
options: {
limit: 10, // specify how many tokens to return
orderBy: "created_at", // specify the order of the results
},
});
console.log(accountOwnedTokens);
}
runExample().catch(console.error);
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 parameter.
The account address we want to get the tokens for.
The address of the collection being queried.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to, before querying.
Optional
options?: TokenStandardArg & PaginationArgs & OrderByArg<Tokens array with the token data.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get tokens owned by a specific account in a specific collection
const accountOwnedTokens = await aptos.getAccountOwnedTokensFromCollectionAddress({
accountAddress: "0x1", // replace with a real account address
collectionAddress: "0x2", // replace with a real collection address
});
console.log(accountOwnedTokens);
}
runExample().catch(console.error);
Queries a specific account resource given an account address and resource type.
The account resource of the specified type.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get the account resource for a specific account address and resource type
const resource = await aptos.getAccountResource({
accountAddress: "0x1", // replace with a real account address
resourceType: "0x1::aptos_coin::AptosCoin"
});
console.log(resource);
}
runExample().catch(console.error);
Queries all account resources given an account address. This function may call the API multiple times to auto paginate through results.
Account resources.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching account resources for a specific account address
const resources = await aptos.getAccountResources({ accountAddress: "0x1" }); // replace with a real account address
console.log(resources);
}
runExample().catch(console.error);
Fetches all subdomain names for a specified account.
The arguments for retrieving subdomains.
The address to retrieve subdomain names for.
Optional parameters for fetching subdomains.
The offset to start from when fetching names.
The number of names to fetch per request.
The order to sort the names by.
Additional filters to apply to the query.
A promise of an array of ANSName.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching subdomain names for a specific account
const subdomains = await aptos.getAccountSubdomains({
accountAddress: "0x1", // replace with a real account address
options: {
limit: 10, // specify the number of subdomains to fetch
offset: 0, // specify the offset for pagination
orderBy: "name", // specify the order by which to sort the names
},
});
console.log(subdomains);
}
runExample().catch(console.error);
Queries the current count of tokens owned by a specified account.
The current count of tokens owned by the account.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get the count of tokens owned by the account
const tokensCount = await aptos.getAccountTokensCount({ accountAddress: "0x1" }); // replace with a real account address
console.log(`Tokens Count: ${tokensCount}`);
}
runExample().catch(console.error);
Queries account transactions given an account address. This function may call the API multiple times to auto paginate and retrieve all account transactions.
The account transactions.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetch transactions for a specific account
const transactions = await aptos.getAccountTransactions({
accountAddress: "0x1", // replace with a real account address
options: {
offset: 0, // starting from the first transaction
limit: 10, // limiting to 10 transactions
},
});
console.log(transactions);
}
runExample().catch(console.error);
Queries the current count of transactions submitted by an account.
Current count of transactions made by an account.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get the count of transactions for a specific account
const accountTransactionsCount = await aptos.getAccountTransactionsCount({
accountAddress: "0x1", // replace with a real account address
minimumLedgerVersion: 1, // specify your own minimum ledger version if needed
});
console.log(accountTransactionsCount);
}
runExample().catch(console.error);
Retrieve a block by its height, allowing for the inclusion of transactions if specified.
The parameters for the block retrieval.
The block with optional transactions included.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve the block at height 5, including transactions
const block = await aptos.getBlockByHeight({ blockHeight: 5, options: { withTransactions: true } });
console.log(block);
}
runExample().catch(console.error);
Retrieves block information by the specified ledger version.
The arguments for retrieving the block.
Block information with optional transactions.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve block information for a specific ledger version
const block = await aptos.getBlockByVersion({ ledgerVersion: 5 });
console.log(block);
}
runExample().catch(console.error);
Retrieves the chain ID of the Aptos blockchain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching the chain ID
const chainId = await aptos.getChainId();
console.log("Chain ID:", chainId);
}
runExample().catch(console.error);
@returns The chain ID of the Aptos blockchain.
Queries the top user transactions based on the specified limit.
GetChainTopUserTransactionsResponse
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetch the top user transactions with a limit of 5
const topUserTransactions = await aptos.getChainTopUserTransactions({ limit: 5 });
console.log(topUserTransactions);
}
runExample().catch(console.error);
Queries data of a specific collection by the collection creator address and the collection name.
This function is deprecated; use getCollectionDataByCreatorAddressAndCollectionName
instead.
If a creator account has two collections with the same name in v1 and v2, you can pass an optional tokenStandard
parameter
to query a specific standard.
The arguments for querying the collection data.
GetCollectionDataResponse - The response type containing the collection data.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Querying collection data by creator address and collection name
const collection = await aptos.getCollectionData({
creatorAddress: "0x1", // replace with a real creator address
collectionName: "myCollection", // specify your collection name
});
console.log(collection);
}
runExample().catch(console.error);
Queries data of a specific collection by the collection ID.
The ID of the collection, which is the same as the address of the collection object.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: TokenStandardArg & PaginationArgsOptional parameters for token standard and pagination.
GetCollectionDataResponse - The response type containing the collection data.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching collection data by collection ID
const collection = await aptos.getCollectionDataByCollectionId({
collectionId: "0x123", // replace with a real collection ID
});
console.log(collection);
}
runExample().catch(console.error);
Retrieves data for a specific collection created by a given creator address. This function allows you to query collection data while optionally specifying a minimum ledger version and pagination options.
GetCollectionDataResponse - The response type containing collection data.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve collection data by creator address
const collectionData = await aptos.getCollectionDataByCreatorAddress({
creatorAddress: "0x1", // replace with a real creator address
minimumLedgerVersion: 1, // specify the minimum ledger version if needed
options: {
tokenStandard: "v2", // specify the token standard if needed
pagination: { limit: 10, offset: 0 } // specify pagination options if needed
}
});
console.log(collectionData);
}
runExample().catch(console.error);
Queries data of a specific collection by the collection creator address and the collection name.
If a creator account has multiple collections with the same name across different versions,
specify the tokenStandard
parameter to query a specific standard.
GetCollectionDataResponse - The response type containing collection data.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching collection data by creator address and collection name
const collection = await aptos.getCollectionDataByCreatorAddressAndCollectionName({
creatorAddress: "0x1", // replace with a real creator address
collectionName: "myCollection",
minimumLedgerVersion: 1, // optional, specify if needed
options: { tokenStandard: "v2" } // optional, specify if needed
});
console.log(collection);
}
runExample().catch(console.error);
Queries the ID of a specified collection. This ID corresponds to the collection's object address in V2, while V1 does not utilize objects and lacks an address.
The collection ID.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching the collection ID for a specific creator and collection name
const collectionId = await aptos.getCollectionId({
creatorAddress: "0x1", // replace with a real creator address
collectionName: "myCollection"
});
console.log("Collection ID:", collectionId);
}
runExample().catch(console.error);
Retrieves the current ownership data of a specified digital asset using its address.
GetCurrentTokenOwnershipResponse containing relevant ownership data of the digital asset.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Getting the current ownership of a digital asset
const digitalAssetOwner = await aptos.getCurrentDigitalAssetOwnership({
digitalAssetAddress: "0x123", // replace with a real digital asset address
});
console.log(digitalAssetOwner);
}
runExample().catch(console.error);
Queries all fungible asset balances.
Optional
args: {Optional parameters for the query.
A list of fungible asset metadata.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching current fungible asset balances
const fungibleAssetBalances = await aptos.getCurrentFungibleAssetBalances();
console.log(fungibleAssetBalances);
}
runExample().catch(console.error);
Queries delegated staking activities for a specific delegator and pool.
The arguments for querying delegated staking activities.
The response containing delegated staking activities.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get delegated staking activities for a specific delegator and pool
const activities = await aptos.getDelegatedStakingActivities({
delegatorAddress: "0x1", // replace with a real delegator address
poolAddress: "0x2", // replace with a real pool address
minimumLedgerVersion: 1, // specify your own if needed
});
console.log(activities);
}
runExample().catch(console.error);
Retrieves the activity data for a specified digital asset using its address.
The parameters for the request.
The address of the digital asset.
Optional
minimumLedgerVersion?: AnyNumberOptional minimum ledger version to sync up to before querying.
Optional
options?: PaginationArgs & OrderByArg<Optional pagination and ordering parameters.
A promise that resolves to the activity data related to the digital asset.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get the activity data for a digital asset
const digitalAssetActivity = await aptos.getDigitalAssetActivity({
digitalAssetAddress: "0x123", // replace with a real digital asset address
});
console.log(digitalAssetActivity);
}
runExample().catch(console.error);
Retrieves digital asset data using the address of a digital asset.
GetTokenDataResponse containing relevant data for the digital asset.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching digital asset data for a specific address
const digitalAsset = await aptos.getDigitalAssetData({
digitalAssetAddress: "0x123", // replace with a real digital asset address
});
console.log(digitalAsset);
}
runExample().catch(console.error);
Fetches all subdomain names for a given domain, excluding the domain itself.
The arguments for fetching subdomains.
A string of the domain name, e.g., "test.apt" or "test" (without the suffix of .apt).
Optional parameters for fetching subdomains.
Optional, the offset to start from when fetching names.
Optional, the number of names to fetch per request.
The order to sort the names by.
Additional filters to apply to the query.
A promise that resolves to an array of ANSName.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching subdomains for a specific domain
const subdomains = await aptos.getDomainSubdomains({
domain: "test", // replace with your domain
options: {
limit: 10, // specify the number of subdomains to fetch
offset: 0, // specify the starting point for fetching
orderBy: "name", // specify the order by which to sort the results
},
});
console.log(subdomains);
}
runExample().catch(console.error);
Retrieve all events from the Aptos blockchain.
An optional where
clause can be provided to filter the results based on specific criteria.
Optional
args: {Optional parameters for the query.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: PaginationArgs & OrderByArg<Optional pagination and filtering options.
GetEventsQuery response type containing the events.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve all events
const events = await aptos.getEvents();
// Retrieve events with filtering by account address
const whereCondition = {
account_address: { _eq: "0x123" }, // replace with a real account address
};
const filteredEvents = await aptos.getEvents({
options: { where: whereCondition },
});
console.log(events);
console.log(filteredEvents);
}
runExample().catch(console.error);
Retrieve the expiration time of a domain name or subdomain name from the contract.
number as a unix timestamp in milliseconds.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get the expiration time for the domain "test.aptos"
const exp = await aptos.getExpiration({ name: "test.aptos" });
// Log the expiration date
console.log(new Date(exp)); // Outputs the expiration date
}
runExample().catch(console.error);
Queries all fungible asset activities and returns a list of their metadata.
Optional
args: {Optional parameters for the query.
A list of fungible asset metadata.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching fungible asset activities
const fungibleAssetActivities = await aptos.getFungibleAssetActivities();
console.log(fungibleAssetActivities);
}
runExample().catch(console.error);
Queries all fungible asset metadata.
Optional
args: {Optional parameters for the query.
A list of fungible asset metadata.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching fungible asset metadata
const fungibleAssets = await aptos.getFungibleAssetMetadata();
console.log(fungibleAssets);
}
runExample().catch(console.error);
Queries the fungible asset metadata for a specific asset type. This function helps retrieve detailed information about a fungible asset based on its type.
A fungible asset metadata item.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve fungible asset metadata by asset type
const fungibleAsset = await aptos.getFungibleAssetMetadataByAssetType({
assetType: "0x1::aptos_coin::AptosCoin" // replace with your asset type
});
console.log(fungibleAsset);
}
runExample().catch(console.error);
Retrieves fungible asset metadata based on the creator address.
This function allows you to query metadata for a specific fungible asset created by a given address.
A fungible asset metadata item.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve fungible asset metadata by creator address
const fungibleAsset = await aptos.getFungibleAssetMetadataByCreatorAddress({
creatorAddress: "0x123", // replace with a real creator address
});
console.log(fungibleAsset);
}
runExample().catch(console.error);
Estimates the gas unit price required to process a transaction on the Aptos blockchain in a timely manner. This helps users to understand the cost associated with their transactions. https://api.mainnet.aptoslabs.com/v1/spec#/operations/estimate_gas_price
An object containing the estimated gas price.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET }); // Specify your network
const aptos = new Aptos(config);
async function runExample() {
// Getting the gas price estimation
const gasPriceEstimation = await aptos.getGasPriceEstimation();
console.log("Estimated Gas Price:", gasPriceEstimation);
}
runExample().catch(console.error);
Queries for the last successful indexer version, providing insight into the ledger version the indexer is updated to, which may lag behind the full nodes.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get the last successful indexer version
const version = await aptos.getIndexerLastSuccessVersion();
console.log(`Last successful indexer version: ${version}`);
}
runExample().catch(console.error);
Queries for the Aptos ledger information.
The Aptos Ledger Info, which includes details such as chain ID, epoch, and ledger version.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching the ledger information
const ledgerInfo = await aptos.getLedgerInfo();
console.log(ledgerInfo);
}
runExample().catch(console.error);
Retrieve module events based on a specified event type. This function allows you to query for events that are associated with a particular module event type in the Aptos blockchain.
The arguments for retrieving module events.
The event type to filter the results.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: PaginationArgs & OrderByArg<Optional pagination and ordering parameters for the event results.
Promise
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve module events for a specific event type
const events = await aptos.getModuleEventsByEventType({
eventType: "0x1::transaction_fee::FeeStatement", // specify the event type
minimumLedgerVersion: 1, // optional: specify minimum ledger version if needed
});
console.log(events); // log the retrieved events
}
runExample().catch(console.error);
Fetches a single name from the indexer based on the provided name argument.
A promise of an ANSName or undefined if the name is not active.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching a name from the indexer
const name = await aptos.getName({ name: "test.aptos" }); // replace with a real name
console.log(name);
}
runExample().catch(console.error);
Queries the current number of delegators in a specified pool. Throws an error if the pool is not found.
The number of delegators for the given pool.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get the number of delegators for a specific pool
const delegators = await aptos.getNumberOfDelegators({ poolAddress: "0x1" }); // replace with a real pool address
console.log(`Number of delegators: ${delegators}`);
}
runExample().catch(console.error);
Retrieves the current number of delegators across all pools.
Optional
args: {Optional parameters for the query.
GetNumberOfDelegatorsForAllPoolsResponse response type containing the number of delegators per pool.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve the number of delegators for all pools
const delegators = await aptos.getNumberOfDelegatorsForAllPools();
console.log(delegators);
}
runExample().catch(console.error);
Fetches the object data based on the specified object address.
Optional
minimumLedgerVersion?: AnyNumberOptional minimum ledger version to wait for.
The object address to retrieve data for.
Optional
options?: PaginationArgs & OrderByArg<Optional configuration options for pagination and ordering.
The object data corresponding to the provided address.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching object data by object address
const objectData = await aptos.getObjectDataByObjectAddress({
objectAddress: "0x1", // replace with a real object address
});
console.log(objectData);
}
runExample().catch(console.error);
Retrieves the digital assets owned by a specified address.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: PaginationArgs & OrderByArg<Optional pagination and ordering parameters for the response.
The address of the owner.
GetOwnedTokensResponse containing ownership data of the digital assets belonging to the ownerAddress.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching the digital assets owned by the specified address
const digitalAssets = await aptos.getOwnedDigitalAssets({
ownerAddress: "0x1", // replace with a real account address
});
console.log(digitalAssets);
}
runExample().catch(console.error);
Retrieve the owner address of a specified domain name or subdomain name from the contract.
AccountAddress if the name is owned, undefined otherwise.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve the owner address of "test.aptos"
const owner = await aptos.getOwnerAddress({ name: "test.aptos" });
console.log(owner); // Logs the owner address or undefined if not owned
}
runExample().catch(console.error);
Fetches the pepper from the Aptos pepper service API.
The arguments for fetching the pepper.
The pepper which is a Uint8Array of length 31.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
const ephemeralKeyPair = new EphemeralKeyPair(); // create a new ephemeral key pair
const jwt = "your_jwt_token"; // replace with a real JWT token
// Fetching the pepper using the provided JWT and ephemeral key pair
const pepper = await aptos.getPepper({
jwt,
ephemeralKeyPair,
// derivationPath: "m/44'/637'/0'/0'/0" // specify your own if needed
});
console.log("Fetched pepper:", pepper);
}
runExample().catch(console.error);
Retrieve the primary name for an account. An account can have multiple names, but only one primary name, which may not exist.
A string if the account has a primary name, undefined otherwise.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve the primary name for the specified account address
const name = await aptos.getPrimaryName({ address: "0x1" }); // replace with a real account address
console.log(name);
}
runExample().catch(console.error);
Query the processor status for a specific processor type.
The processor type to query.
The status of the specified processor type.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Get the processor status for the account transactions processor
const status = await aptos.getProcessorStatus("account_transactions_processor");
console.log(status);
}
runExample().catch(console.error);
Fetches a proof from the Aptos prover service API.
The arguments for fetching the proof.
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
uidKey?: stringA key in the JWT token to use to set the uidVal in the IdCommitment.
The proof which is represented by a ZeroKnowledgeSig.
import { Aptos, AptosConfig, Network, EphemeralKeyPair, getPepper } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
const jwt = "your_jwt_token"; // replace with a real JWT token
const ephemeralKeyPair = new EphemeralKeyPair(); // create a new ephemeral key pair
// Fetch the proof using the getProof function
const proof = await aptos.getProof({
jwt,
ephemeralKeyPair,
pepper: await getPepper({}), // fetch the pepper if not provided
uidKey: "sub", // specify the uid key
});
console.log("Fetched proof:", proof);
}
runExample().catch(console.error);
Returns a signing message for a transaction, allowing a user to sign it using their preferred method before submission to the network.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
const transaction = await aptos.transaction.build.simple({
sender: "0x1", // replace with a real sender address
data: {
function: "0x1::aptos_account::transfer",
functionArguments: ["0x2", 100], // replace with a real destination address
},
});
const message = await aptos.getSigningMessage({ transaction });
console.log(message);
}
runExample().catch(console.error);
Queries for a specific item in a table identified by the handle and the key for the item. This function allows you to retrieve structured data from a table in the Aptos blockchain.
Table item value rendered in JSON.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve a table item from the Aptos blockchain
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
},
});
console.log(tableItem);
}
runExample().catch(console.error);
Queries for table items data with optional filtering and pagination. This function allows you to retrieve specific data from a table based on provided criteria.
The arguments for querying table items data.
Optional
minimumLedgerVersion?: AnyNumberOptional minimum ledger version to wait for before querying.
Optional
options?: PaginationArgs & WhereArg<TableItemsBoolExp> & OrderByArg<Optional parameters for pagination and filtering.
GetTableItemsDataResponse
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve table items data with specific filtering options
const data = await aptos.getTableItemsData({
minimumLedgerVersion: 1, // specify your own minimum ledger version if needed
options: {
where: {
table_handle: { _eq: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca" },
transaction_version: { _eq: "0" }
},
limit: 10, // specify your own limit if needed
},
});
console.log(data);
}
runExample().catch(console.error);
Queries for the metadata of table items, allowing for filtering and pagination.
The parameters for the query.
GetTableItemsMetadataResponse
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching table items metadata with a filter condition
const data = await aptos.getTableItemsMetadata({
minimumLedgerVersion: 1, // specify your own minimum ledger version if needed
options: {
where: { handle: { _eq: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca" } },
limit: 10, // specify your own limit if needed
},
});
console.log(data);
}
runExample().catch(console.error);
Retrieve the target address of a domain or subdomain name, which indicates the address the name points to for use on-chain. Note that the target address can point to addresses that do not own the name.
AccountAddress if the name has a target, undefined otherwise.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Retrieve the target address for the specified domain name
const targetAddr = await aptos.getTargetAddress({ name: "test.aptos" });
console.log(targetAddr); // Logs the target address, e.g., 0x123...
}
runExample().catch(console.error);
Queries on-chain transactions by their transaction hash, returning both pending and committed transactions.
The transaction from the mempool (pending) or the on-chain (committed) transaction.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetch a transaction by its hash
const transaction = await aptos.getTransactionByHash({ transactionHash: "0x123" }); // replace with a real transaction hash
console.log(transaction);
}
runExample().catch(console.error);
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.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetching a transaction by its version
const transaction = await aptos.getTransactionByVersion({ ledgerVersion: 1 }); // replace 1 with a real version
console.log(transaction);
}
runExample().catch(console.error);
Queries on-chain transactions, excluding pending transactions. Use this function to retrieve historical transactions from the blockchain.
An array of on-chain transactions.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Fetch transactions with pagination
const transactions = await aptos.getTransactions({
options: {
offset: 0, // Start from the first transaction
limit: 10, // Limit to 10 results
},
});
console.log(transactions);
}
runExample().catch(console.error);
Defines if the specified transaction is currently in a pending state. This function helps you determine the status of a transaction using its hash.
true
if the transaction is in a pending state and false
otherwise.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Check if the transaction is pending using its hash
const isPendingTransaction = await aptos.isPendingTransaction({ transactionHash: "0x123" }); // replace with a real transaction hash
console.log("Is the transaction pending?", isPendingTransaction);
}
runExample().catch(console.error);
Looks up the account address for a given authentication key, handling both rotated and non-rotated keys.
Promise
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Look up the original account address for a given authentication key
const accountAddress = await aptos.lookupOriginalAccountAddress({
authenticationKey: "0x1", // replace with a real authentication key
});
console.log("Original Account Address:", accountAddress);
}
runExample().catch(console.error);
Create a transaction to mint a digital asset into the creator's account within an existing collection. This function helps you generate a transaction that can be simulated or submitted to the blockchain for minting a digital asset.
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 transaction generation options.
Optional
propertyKeys?: string[]Optional array of property keys for the digital asset.
Optional
propertyTypes?: (Optional array of property types for the digital asset.
Optional
propertyValues?: PropertyValue[]Optional array of property values for the digital asset.
The URI to additional info about the digital asset.
A SimpleTransaction that can be simulated or submitted to the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Creating a transaction to mint a digital asset
const transaction = await aptos.mintDigitalAssetTransaction({
creator: Account.generate(), // replace with a real account
collection: "MyCollection",
description: "This is a digital asset.",
name: "MyDigitalAsset",
uri: "https://example.com/my-digital-asset",
});
console.log(transaction);
}
runExample().catch(console.error);
Mint a soul bound digital asset into a recipient's account. This function allows you to create a unique digital asset that is bound to a specific account.
The arguments for minting the soul bound transaction.
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?: InputGenerateTransactionOptionsAdditional options for generating the transaction.
Optional
propertyKeys?: string[]The property keys for storing on-chain properties.
Optional
propertyTypes?: (The type of property values.
Optional
propertyValues?: PropertyValue[]The 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 the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Mint a soul bound digital asset
const transaction = await aptos.mintSoulBoundTransaction({
account: Account.generate(), // Replace with a real account
collection: "collectionName",
description: "collectionDescription",
name: "digitalAssetName",
uri: "digital-asset-uri.com",
recipient: "0x123" // Replace with a real recipient account address
});
console.log(transaction);
}
runExample().catch(console.error);
Generates a transaction to publish a Move package to the blockchain. This function helps you create a transaction that can be simulated or submitted to the chain for publishing a package.
To get the metadataBytes
and byteCode
, can compile using Aptos CLI with command
aptos move compile --save-metadata ...
,
https://aptos.dev/tutorials/your-first-dapp/#step-4-publish-a-move-module
The arguments for publishing the package.
The publisher account.
The package metadata bytes.
An array of the bytecode of each module in the package in compiler output order.
Optional
options?: InputGenerateTransactionOptionsOptional settings for generating the transaction.
A SimpleTransaction that can be simulated or submitted to the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Replace with a real account address
const account = "0x1";
const metadataBytes = "0x..."; // replace with real metadata bytes
const byteCode = "0x..."; // replace with real module bytecode
const transaction = await aptos.publishPackageTransaction({
account,
metadataBytes,
moduleBytecode: [byteCode],
});
console.log(transaction);
}
runExample().catch(console.error);
Retrieves data from the Aptos Indexer using a GraphQL query. This function allows you to execute complex queries to fetch specific data from the Aptos blockchain.
The provided T type.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Querying the Aptos Indexer for ledger information
const topUserTransactions = await aptos.queryIndexer({
query: `query MyQuery {
ledger_infos {
chain_id
}
}`
});
console.log(topUserTransactions);
}
runExample().catch(console.error);
Registers a new name.
This function allows you to register a domain or subdomain name with specific expiration policies and options.
The sender account.
A string of the name to register. This can be inclusive or exclusive of the .apt suffix. Examples include: "test", "test.apt", "test.aptos.apt", etc.
An object with the expiration policy of the name.
'domain' | 'subdomain:follow-domain' | 'subdomain:independent'.
An epoch number in milliseconds of the date when the subdomain will expire. Only applicable when the policy is set to 'subdomain:independent'.
Determines if the subdomain being minted is soul-bound. Applicable only to subdomains.
optional - The address the domain name will resolve to. If not provided, the sender's address will be used.
optional - The address to send the domain name to. If not provided, the transaction will be sent to the router.
SimpleTransaction
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Registering a subdomain name assuming def.apt is already registered and belongs to the sender alice.
const txn = await aptos.registerName({
sender: "0x1", // replace with a real sender account
name: "test.aptos.apt",
expiration: {
policy: "subdomain:independent",
expirationDate: Date.now() + 30 * 24 * 60 * 60 * 1000, // expires in 30 days
},
});
console.log("Transaction:", txn);
}
runExample().catch(console.error);
Remove a digital asset property from the blockchain. This function allows you to delete an existing property associated with a digital asset.
The parameters required to remove the digital asset property.
The account that mints the digital asset.
The digital asset address.
Optional
digitalAssetType?: `${string}::${string}::${string}`Optional. The type of the digital asset.
Optional
options?: InputGenerateTransactionOptionsOptional. Additional options for generating the transaction.
The 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 the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Remove a digital asset property
const transaction = await aptos.removeDigitalAssetPropertyTransaction({
creator: Account.generate(), // replace with a real account
propertyKey: "newKey",
propertyType: "BOOLEAN",
propertyValue: true,
digitalAssetAddress: "0x123", // replace with a real digital asset address
});
console.log(transaction);
}
runExample().catch(console.error);
Renews a domain name for one year. If a domain name was minted with V1 of the contract, it will automatically be upgraded to V2 via this transaction.
The arguments for renewing the domain.
A string representing the domain to renew. Subdomains cannot be renewed.
Optional
options?: InputGenerateTransactionOptionsOptional transaction options.
The sender account, which must be the domain owner.
Optional
years?: 1The number of years to renew the name. Currently, only one year is permitted.
SimpleTransaction
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Renew the domain "test" for one year
const transaction = await aptos.renewDomain({
sender: Account.generate(), // replace with a real account
name: "test"
});
console.log(transaction);
}
runExample().catch(console.error);
Rotate an account's authentication key. After rotation, only the new private key can be used to sign transactions for the account. Note: Only legacy Ed25519 scheme is supported for now. More info: https://aptos.dev/guides/account-management/key-rotation/
PendingTransactionResponse
import { Aptos, AptosConfig, Network, Account, PrivateKey } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Rotate the authentication key for an account
const response = await aptos.rotateAuthKey({
// replace with a real account
fromAccount: Account.generate(),
// replace with a real private key
toNewPrivateKey: new PrivateKey("0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"),
});
console.log(response);
}
runExample().catch(console.error);
Set the digital asset description to provide additional context or information about the asset.
The parameters for setting the digital asset description.
The creator account responsible for the digital asset.
The digital asset description to be set.
The address of the digital asset.
Optional
digitalAssetType?: `${string}::${string}::${string}`Optional. The type of the digital asset.
Optional
options?: InputGenerateTransactionOptionsOptional. Additional options for generating the transaction.
A SimpleTransaction that can be simulated or submitted to the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Set the digital asset description
const transaction = await aptos.setDigitalAssetDescriptionTransaction({
creator: Account.generate(), // replace with a real account
description: "This is a digital asset description.",
digitalAssetAddress: "0x123", // replace with a real digital asset address
});
console.log(transaction);
}
runExample().catch(console.error);
Set the digital asset name, allowing you to define a name for a specific digital asset on the blockchain.
The parameters for setting the digital asset name.
The creator account responsible for the transaction.
The address of the digital asset.
Optional
digitalAssetType?: `${string}::${string}::${string}`Optional. The type of the digital asset, represented as a Move struct ID.
The desired name for the digital asset.
Optional
options?: InputGenerateTransactionOptionsOptional. Additional options for generating the transaction.
A SimpleTransaction that can be simulated or submitted to the blockchain.
import { Aptos, AptosConfig, Network, Account } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
const creator = Account.generate(); // Generate a new account for the creator
const digitalAssetAddress = "0x123"; // replace with a real digital asset address
// Set the digital asset name
const transaction = await aptos.setDigitalAssetNameTransaction({
creator: creator,
name: "digitalAssetName",
digitalAssetAddress: digitalAssetAddress,
});
console.log(transaction);
}
runExample().catch(console.error);
Set the URI for a digital asset, allowing you to associate a unique identifier with the asset.
The parameters for the transaction.
The creator account initiating the transaction.
The address of the digital asset.
Optional
digitalAssetType?: `${string}::${string}::${string}`Optional. The type of the digital asset.
Optional
options?: InputGenerateTransactionOptionsOptional. Additional options for generating the transaction.
The digital asset URI to be set.
A SimpleTransaction that can be simulated or submitted to the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Set the URI for a digital asset
const transaction = await aptos.setDigitalAssetURITransaction({
creator: Account.generate(), // Replace with a real creator account
uri: "digital-asset-uri.com",
digitalAssetAddress: "0x123", // Replace with a real digital asset address
});
console.log(transaction);
}
runExample().catch(console.error);
Sets the primary name for the sender account, allowing them to designate a single primary name among potentially multiple names. An account may not have a primary name.
The arguments for setting the primary name.
SimpleTransaction
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Set the primary name for the sender account
const sender = Account.generate(); // replace with a real account
await aptos.setPrimaryName({ sender, name: "test.aptos" });
const primaryName = await aptos.getPrimaryName({ address: sender.accountAddress });
console.log("Primary Name:", primaryName); // Should log: "Primary Name: test.aptos"
}
runExample().catch(console.error);
Sets the target address of a domain or subdomain name, pointing it to a specified address for use on-chain. The target address can be different from the owner of the name.
The arguments for setting the target address.
The AccountAddressInput of the address to set the domain or subdomain to.
A string representing the domain or subdomain name (e.g., "test.aptos").
Optional
options?: InputGenerateTransactionOptionsOptional settings for generating the transaction.
The account initiating the transaction.
SimpleTransaction
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Setting the target address for a domain name
const sender = Account.generate(); // replace with a real account
const address = "0x1"; // replace with a real account address
await aptos.setTargetAddress({
sender: sender,
name: "test.aptos",
address: address,
});
const targetAddress = await aptos.getTargetAddress({ name: "test.aptos" });
console.log(targetAddress); // Should log the address set for "test.aptos"
}
runExample().catch(console.error);
Sign a transaction that can later be submitted to the chain. This function is essential for ensuring the authenticity of the transaction by using the provided account's signing capabilities.
AccountAuthenticator - The authenticator for the signed transaction.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
const sender = Account.generate(); // Generate a new account for signing
const transaction = await aptos.transaction.build.simple({
sender: sender.accountAddress,
data: {
function: "0x1::aptos_account::transfer",
functionArguments: [ "0x1", 100 ], // replace with a real account address and amount
},
});
const signedTransaction = await aptos.transaction.sign({
signer: sender,
transaction,
}); // Sign the transaction
console.log("Signed Transaction:", signedTransaction);
}
runExample().catch(console.error);
Sign and submit a single signer transaction as the fee payer to chain given an authenticator by the sender of the transaction.
PendingTransactionResponse
const transaction = await aptos.transaction.build.simple({sender: alice.accountAddress, feePayer: true ...})
const senderAuthenticator = alice.signTransactionWithAuthenticator(transaction)
const pendingTransaction = await aptos.signAndSubmitAsFeePayer({
senderAuthenticator,
feePayer: bob,
transaction,
})
Sign and submit a single signer transaction to the blockchain. This function allows you to execute a transaction after signing it with the specified account.
The arguments for signing and submitting the transaction.
The signer account to sign the transaction.
An instance of a RawTransaction, plus optional secondary/fee payer addresses.
PendingTransactionResponse
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
const sender = Account.generate(); // Generate a new account for sending the transaction
const transaction = await aptos.transaction.build.simple({
sender: sender.accountAddress,
data: {
function: "0x1::aptos_account::transfer",
functionArguments: [ "0x1", 100 ], // replace with a real account address
},
});
// Sign and submit the transaction
const pendingTransaction = await aptos.signAndSubmitTransaction({
signer: sender,
transaction,
});
console.log(pendingTransaction);
}
runExample().catch(console.error);
Sign a transaction as a fee payer that can later be submitted to the chain. This function ensures that the transaction is marked with the fee payer's address, allowing it to be processed correctly.
AccountAuthenticator - The authenticator for the signed transaction.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
const sender = Account.generate(); // Generate a new account for the fee payer
const transaction = await aptos.transaction.build.simple({
// All transactions on Aptos are implemented via smart contracts.
function: "0x1::aptos_account::transfer",
functionArguments: [sender.accountAddress, 100],
feePayerAddress: sender.accountAddress, // Set the fee payer address
});
const signedTransaction = await aptos.transaction.signAsFeePayer({
signer: sender,
transaction,
});
console.log("Signed transaction as fee payer:", signedTransaction);
}
runExample().catch(console.error);
Generate a transfer coin transaction that can be simulated, signed, and submitted. This function helps you create a transaction to transfer a specified amount of coins from one account to another within the Aptos network.
The arguments for the transfer transaction.
The amount of coins to transfer.
Optional
coinType?: `${string}::${string}::${string}`Optional. The coin struct type to transfer. Defaults to 0x1::aptos_coin::AptosCoin.
Optional
options?: InputGenerateTransactionOptionsOptional. Additional options for generating the transaction.
The recipient account address.
The sender account address.
SimpleTransaction
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Generate a transfer coin transaction
const transaction = await aptos.transferCoinTransaction({
sender: "0x1", // replace with a real sender account address
recipient: "0x2", // replace with a real recipient account address
amount: 10,
});
console.log(transaction);
}
runExample().catch(console.error);
Transfer ownership of a non-fungible digital asset. This function allows you to transfer a digital asset only if it is not frozen, meaning the ownership transfer is not disabled.
The arguments for transferring the digital asset.
The address of the digital asset being transferred.
Optional
digitalAssetType?: `${string}::${string}::${string}`Optional. The type of the digital asset, defaults to "0x4::token::Token".
Optional
options?: InputGenerateTransactionOptionsOptional. Additional options for generating the transaction.
The account address of the recipient.
The sender account of the current digital asset owner.
A SimpleTransaction that can be simulated or submitted to the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Transfer a digital asset
const transaction = await aptos.transferDigitalAssetTransaction({
sender: Account.generate(), // replace with a real sender account
digitalAssetAddress: "0x123", // replace with a real digital asset address
recipient: "0x456", // replace with a real recipient account address
});
console.log(transaction);
}
runExample().catch(console.error);
Transfer a specified amount of fungible asset from the sender's primary store to the recipient's primary store. This method allows you to transfer any fungible asset, including fungible tokens.
The arguments for the transfer operation.
The number of assets to transfer.
The fungible asset account address. For example, if you’re transferring USDT, this would be the USDT address.
Optional
options?: InputGenerateTransactionOptionsOptional parameters for generating the transaction.
The recipient account address.
The sender account.
A SimpleTransaction that can be simulated or submitted to the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Transfer fungible asset from sender to recipient
const transaction = await aptos.transferFungibleAsset({
sender: Account.generate(), // replace with a real sender account
fungibleAssetMetadataAddress: "0x123", // replace with a real fungible asset address
recipient: "0x456", // replace with a real recipient account
amount: 5
});
console.log(transaction);
}
runExample().catch(console.error);
Unfreeze the ability to transfer a digital asset. This function allows the specified creator account to unfreeze the transfer of a digital asset identified by its address.
The parameters for unfreezing the digital asset transfer.
The creator account that is unfreezing the digital asset transfer.
The address of the digital asset to unfreeze.
Optional
digitalAssetType?: `${string}::${string}::${string}`Optional. The type of the digital asset being unfrozen.
Optional
options?: InputGenerateTransactionOptionsOptional. Additional options for generating the transaction.
A SimpleTransaction that can be simulated or submitted to the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Unfreeze the ability to transfer a digital asset
const transaction = await aptos.unfreezeDigitalAssetTransaferTransaction({
creator: Account.generate(), // replace with a real creator account
digitalAssetAddress: "0x123", // replace with a real digital asset address
});
console.log(transaction);
}
runExample().catch(console.error);
Update a digital asset property on-chain.
The parameters for updating the digital asset property.
The account that mints the digital asset.
The address of the digital asset.
Optional
digitalAssetType?: `${string}::${string}::${string}`Optional. The type of the digital asset.
Optional
options?: InputGenerateTransactionOptionsOptional. Additional options for generating the transaction.
The 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 the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Update a digital asset property
const transaction = await aptos.updateDigitalAssetPropertyTransaction({
creator: Account.generate(), // replace with a real account
propertyKey: "newKey",
propertyType: "BOOLEAN",
propertyValue: false,
digitalAssetAddress: "0x123", // replace with a real digital asset address
});
console.log(transaction);
}
runExample().catch(console.error);
Update a typed digital asset property on-chain. This function allows you to modify the properties of a digital asset, enabling dynamic updates to its attributes.
The arguments for updating the digital asset property.
The account that mints the digital asset.
The digital asset address.
Optional
digitalAssetType?: `${string}::${string}::${string}`(Optional) The type of the digital asset.
Optional
options?: InputGenerateTransactionOptions(Optional) Additional options for generating the transaction.
The 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 the chain.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Update a typed digital asset property
const transaction = await aptos.updateDigitalAssetTypedPropertyTransaction({
creator: Account.generate(), // replace with a real account
propertyKey: "typedKey",
propertyType: "U8",
propertyValue: 2,
digitalAssetAddress: "0x123", // replace with a real digital asset address
});
console.log(transaction);
}
runExample().catch(console.error);
This installs a set of FederatedJWKs at an address for a given iss.
It will fetch the JSON Web Keyset (JWK) set from the well-known endpoint and update the FederatedJWKs at the sender's address to reflect it.
The pending transaction that results from submission.
Waits for a transaction to move past the pending state and provides the transaction response. 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.
The transaction on-chain response.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Wait for a transaction to complete using its hash
const transactionHash = "0x123"; // replace with a real transaction hash
const transactionResponse = await aptos.waitForTransaction({
transactionHash,
options: {
timeoutSecs: 30, // specify your own timeout if needed
checkSuccess: true,
},
});
console.log(transactionResponse);
}
runExample().catch(console.error);
Initializes a new instance of the Aptos client with the provided configuration settings. This allows you to interact with various Aptos functionalities such as accounts, transactions, and events.