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.
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.
Optionalsettings: AptosSettingsOptional configuration settings for the Aptos client.
Optional Readonlyclient?: ClientOptional ReadonlyclientConfig?: ClientConfigOptional Readonlyfaucet?: stringOptional ReadonlyfaucetConfig?: FaucetConfigOptional Readonlyfullnode?: stringOptional ReadonlyfullnodeConfig?: FullNodeConfigOptional Readonlyindexer?: stringOptional ReadonlyindexerConfig?: IndexerConfigOptional Readonlynetwork?: NetworkOptional Readonlypepper?: stringOptional Readonlyprover?: 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);
Readonlyclient: ClientThe client instance the SDK uses. Defaults to `@aptos-labs/aptos-client
Optional ReadonlyclientConfig?: ClientConfigOptional client configurations
Optional Readonlyfaucet?: stringThe optional hardcoded faucet URL to send requests to instead of using the network
Optional ReadonlyfaucetConfig?: FaucetConfigOptional specific Faucet configurations
Optional Readonlyfullnode?: stringThe optional hardcoded fullnode URL to send requests to instead of using the network
Optional ReadonlyfullnodeConfig?: ClientHeadersTypeOptional specific Fullnode configurations
Optional Readonlyindexer?: stringThe optional hardcoded indexer URL to send requests to instead of using the network
Optional ReadonlyindexerConfig?: ClientHeadersTypeOptional specific Indexer configurations
Readonlynetwork: NetworkThe Network that this SDK is associated with. Defaults to DEVNET
Optional Readonlypepper?: stringThe optional hardcoded pepper service URL to send requests to instead of using the network
Optional Readonlyprover?: 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 the network
nodeUrl: "https://testnet.aptos.dev", // specify the node URL
});
// Initialize the Aptos client
const aptos = new Aptos(config);
console.log("Aptos client initialized:", aptos);
}
runExample().catch(console.error);
Build a multi-agent transaction that allows multiple signers to authorize a transaction.
The parameters for creating the multi-agent transaction.
The transaction data.
Optionaloptions?: InputGenerateTransactionOptionsOptional transaction configurations.
An array of the secondary signers' account addresses.
The sender account address.
OptionalwithFeePayer?: booleanWhether there is a fee payer for the transaction.
MultiAgentTransaction
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
async function runExample() {
// Build a multi-agent transaction
const transaction = await aptos.multiAgent({
sender: "0x1", // replace with a real sender account address
data: {
// Transaction data structure
function: "0x1::aptos_account::transfer",
functionArguments: ["0x2", 100], // replace with a real destination account address and amount
},
secondarySignerAddresses: ["0x3", "0x4"], // replace with real secondary signer addresses
options: {
// Optional transaction configurations
maxGasAmount: "1000",
gasUnitPrice: "1",
},
});
console.log(transaction);
}
runExample().catch(console.error);
Build a simple transaction.
This function allows you to create a transaction with specified sender and data.
The transaction data.
Optionaloptions?: InputGenerateTransactionOptionsOptional transaction configurations.
The sender account address.
OptionalwithFeePayer?: booleanWhether there is a fee payer for 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() {
// Build a simple transaction
const transaction = await aptos.transaction.simple({
sender: "0x1", // replace with a real sender account address
data: {
function: "0x1::aptos_account::transfer",
functionArguments: ["0x2", 100], // replace with a real destination account address
},
options: {
gasUnitPrice: 100, // specify your own gas unit price if needed
maxGasAmount: 1000, // specify your own max gas amount if needed
},
});
console.log(transaction);
}
runExample().catch(console.error);
Build a transaction from a series of Move calls.
This function allows you to create a transaction with a list of Move calls.
Right now we only tested this logic with single signer and we will add support for mutli agent transactions if needed.
The closure to construct the list of calls.
Optionaloptions?: InputGenerateTransactionOptionsOptional transaction configurations.
The sender account address.
OptionalwithFeePayer?: booleanWhether there is a fee payer for 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() {
// Build a transaction from a chained series of Move calls.
const transaction = await aptos.transaction.build.scriptComposer({
sender: "0x1", // replace with a real sender account address
builder: builder: async (builder) => {
const coin = await builder.addBatchedCalls({
function: "0x1::coin::withdraw",
functionArguments: [CallArgument.new_signer(0), 1],
typeArguments: ["0x1::aptos_coin::AptosCoin"],
});
// Pass the returned value from the first function call to the second call
const fungibleAsset = await builder.addBatchedCalls({
function: "0x1::coin::coin_to_fungible_asset",
functionArguments: [coin[0]],
typeArguments: ["0x1::aptos_coin::AptosCoin"],
});
await builder.addBatchedCalls({
function: "0x1::primary_fungible_store::deposit",
functionArguments: [singleSignerED25519SenderAccount.accountAddress, fungibleAsset[0]],
typeArguments: [],
});
return builder;
},
options: {
gasUnitPrice: 100, // specify your own gas unit price if needed
maxGasAmount: 1000, // specify your own max gas amount if needed
},
});
console.log(transaction);
}
runExample().catch(console.error);
A class to handle all
Buildtransaction operations.