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 new Aptos client with testnet configuration
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
console.log("Aptos client initialized:", aptos);
}
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.
Object that describes the table item, including key and value types.
A pointer to where that table is stored.
Optional
options?: LedgerVersionArgTable 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
minimumOptional 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.
Optional
minimumOptional minimum ledger version to wait for before querying.
Optional
options?: PaginationArgs & WhereArg<TableMetadatasBoolExp> & OrderByArg<{ Optional parameters for pagination and filtering.
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);
A class to query all
Table
Aptos related queries.