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);
Generate a transfer coin transaction that can be simulated, signed, and submitted. This function helps you create a transaction to transfer a specified amount of coins from one account to another within the Aptos network.
The arguments for the transfer transaction.
The amount of coins to transfer.
Optional
coinOptional. The coin struct type to transfer. Defaults to 0x1::aptos_coin::AptosCoin.
Optional
options?: InputGenerateTransactionOptionsOptional. Additional options for generating the transaction.
The recipient account address.
The sender account address.
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() {
// Generate a transfer coin transaction
const transaction = await aptos.transferCoinTransaction({
sender: "0x1", // replace with a real sender account address
recipient: "0x2", // replace with a real recipient account address
amount: 10,
});
console.log(transaction);
}
runExample().catch(console.error);
A class to handle all
Coin
operations.