Initializes a new instance of the Aptos client with the specified configuration. This allows you to interact with the Aptos blockchain using the provided settings.
The configuration settings for the Aptos client.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
async function runExample() {
// Create a configuration for the Aptos client
const config = new AptosConfig({ network: Network.TESTNET }); // Specify your desired network
// Initialize the Aptos client with the configuration
const aptos = new Aptos(config);
console.log("Aptos client initialized:", aptos);
}
runExample().catch(console.error);
Add 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);
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.
Options for creating a collection, allowing customization of various attributes such as supply limits, mutability of metadata, and royalty settings.
Optional
maxSupply?: AnyNumberOptional
mutableDescription?: booleanOptional
mutableRoyalty?: booleanOptional
mutableTokenDescription?: booleanOptional
mutableTokenName?: booleanOptional
mutableTokenProperties?: booleanOptional
mutableTokenURI?: booleanOptional
mutableURI?: booleanOptional
royaltyDenominator?: numberOptional
royaltyNumerator?: numberOptional
tokensBurnableByCreator?: booleanOptional
tokensFreezableByCreator?: booleanA 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);
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);
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.
The name of the collection.
The address of the collection's creator.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: TokenStandardArgOptional parameters for the query.
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.
The address of the collection's creator.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: TokenStandardArg & PaginationArgsGetCollectionDataResponse - 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.
The name of the collection.
The address of the collection's creator.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: TokenStandardArg & PaginationArgsGetCollectionDataResponse - 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 name of the collection.
The address of the collection's creator.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: TokenStandardArgThe 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.
The parameters for the request.
The address of the digital asset.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
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);
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.
The parameters for the request.
The address of the digital asset.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
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);
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);
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);
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);
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);
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);
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);
A class to query all
DigitalAsset
related queries on Aptos.