Initializes a new instance of the Aptos class with the provided configuration. This allows you to interact with the Aptos blockchain using the specified network settings.
The configuration settings for connecting to the Aptos network.
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 own network if needed
// Initialize the Aptos client with the configuration
const aptos = new Aptos(config);
console.log("Aptos client initialized:", aptos);
}
runExample().catch(console.error);
Queries all fungible asset balances.
Optional
args: { Optional parameters for the query.
Optional
minimumOptional ledger version to sync up to, before querying.
Optional
options?: PaginationArgs & WhereArg<CurrentFungibleAssetBalancesBoolExp>Optional configuration for pagination and filtering.
A list of fungible asset metadata.
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 all fungible asset activities and returns a list of their metadata.
Optional
args: { Optional parameters for the query.
Optional
minimumOptional ledger version to sync up to, before querying.
Optional
options?: PaginationArgs & WhereArg<FungibleAssetActivitiesBoolExp>Optional configuration for pagination and filtering.
A list of fungible asset metadata.
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.
Optional
minimumOptional ledger version to sync up to before querying.
Optional
options?: PaginationArgs & WhereArg<FungibleAssetMetadataBoolExp>Optional configuration for pagination and filtering.
A list of fungible asset metadata.
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.
The parameters for the query.
The creator address of the fungible asset.
Optional
minimumOptional ledger version to sync up to before querying.
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);
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);
A class for querying and managing fungible asset-related operations on the Aptos blockchain.