Creates an 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.
Represents the configuration settings for an Aptos SDK client instance. This class allows customization of various endpoints and client settings.
Initializes an instance of the Aptos client with the specified settings. This allows users to configure various aspects of the client, such as network and endpoints.
Optional
settings: AptosSettingsOptional configuration settings for the Aptos client.
Optional
Readonly
client?: ClientOptional
Readonly
clientConfig?: ClientConfigOptional
Readonly
faucet?: stringOptional
Readonly
faucetConfig?: FaucetConfigOptional
Readonly
fullnode?: stringOptional
Readonly
fullnodeConfig?: FullNodeConfigOptional
Readonly
indexer?: stringOptional
Readonly
indexerConfig?: IndexerConfigOptional
Readonly
network?: NetworkOptional
Readonly
pepper?: stringOptional
Readonly
prover?: stringimport { 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 the network
const aptos = new Aptos(config);
console.log("Aptos client initialized:", aptos);
}
runExample().catch(console.error);
Readonly
client: ClientThe client instance the SDK uses. Defaults to `@aptos-labs/aptos-client
Optional
Readonly
clientConfig?: ClientConfigOptional client configurations
Optional
Readonly
faucet?: stringThe optional hardcoded faucet URL to send requests to instead of using the network
Optional
Readonly
faucetConfig?: FaucetConfigOptional specific Faucet configurations
Optional
Readonly
fullnode?: stringThe optional hardcoded fullnode URL to send requests to instead of using the network
Optional
Readonly
fullnodeConfig?: ClientHeadersTypeOptional specific Fullnode configurations
Optional
Readonly
indexer?: stringThe optional hardcoded indexer URL to send requests to instead of using the network
Optional
Readonly
indexerConfig?: ClientHeadersTypeOptional specific Indexer configurations
Readonly
network: NetworkThe Network that this SDK is associated with. Defaults to DEVNET
Optional
Readonly
pepper?: stringThe optional hardcoded pepper service URL to send requests to instead of using the network
Optional
Readonly
prover?: stringThe optional hardcoded prover service URL to send requests to instead of using the network
Returns the URL endpoint to send the request to based on the specified API type. If a custom URL was provided in the configuration, that URL is returned. Otherwise, the URL endpoint is derived from the network.
The type of Aptos API to get the URL for. This can be one of the following: FULLNODE, FAUCET, INDEXER, PEPPER, PROVER.
import { Aptos, AptosConfig, Network, AptosApiType } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Getting the request URL for the FULLNODE API
const url = config.getRequestUrl(AptosApiType.FULLNODE);
console.log("Request URL for FULLNODE:", url);
}
runExample().catch(console.error);
Checks if the provided URL is a known pepper service endpoint.
The URL to check against the known pepper service endpoints.
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 url = "https://example.pepper.service"; // replace with a real pepper service URL
// Check if the URL is a known pepper service endpoint
const isPepperService = config.isPepperServiceRequest(url);
console.log(`Is the URL a known pepper service? ${isPepperService}`);
}
runExample().catch(console.error);
Checks if the provided URL is a known prover service endpoint.
The URL to check against known prover service endpoints.
A boolean indicating whether the URL is a known prover service endpoint.
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
// Check if the URL is a known prover service endpoint
const url = "https://prover.testnet.aptos.dev"; // replace with a real URL if needed
const isProver = config.isProverServiceRequest(url);
console.log(`Is the URL a known prover service? ${isProver}`);
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 network
// Initialize the Aptos client with the configuration
const aptos = new Aptos(config);
console.log("Aptos client initialized:", aptos);
}
runExample().catch(console.error);
Queries delegated staking activities for a specific delegator and pool.
The arguments for querying delegated staking activities.
The address of the delegator.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
The address of the staking pool.
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);
Queries the current number of delegators in a specified pool. Throws an error if the pool is not found.
The parameters for the query.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
The address of the pool to query.
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.
Optional
minimumLedgerVersion?: AnyNumberOptional ledger version to sync up to before querying.
Optional
options?: OrderByArg<{ num_active_delegator?: any; pool_address?: null | string }>Optional ordering options for the response.
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);
A class to query all
Staking
related queries on Aptos.