### Build and Test Examples Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/AGENTS.md Builds the local SDK, installs dependencies for an example, builds the example, and runs its tests. ```bash pnpm build cd examples/typescript pnpm install pnpm build pnpm test ``` -------------------------------- ### Run Simple Transfer Example Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/media/README.md Navigate to the javascript examples directory, install dependencies, and run the 'simple_transfer' example. ```bash cd examples/javascript pnpm install pnpm run simple_transfer ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/media/README.md After updating package.json, install dependencies and run tests to verify the setup with the published SDK. ```bash pnpm install pnpm test ``` -------------------------------- ### Start Client Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/projects/gas-station/README.md Starts the Gas Station client using pnpm. ```bash pnpm start-client ``` -------------------------------- ### Start Server Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/projects/gas-station/README.md Starts the Gas Station server using pnpm. ```bash pnpm start-server ``` -------------------------------- ### Submit a Simple Transfer Transaction Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/README.md This example demonstrates the full lifecycle of submitting a simple APT transfer transaction, including building, simulating, signing, submitting, and waiting for the transaction to be executed. Ensure the SDK is installed and accounts are funded before running. ```typescript /** * This example shows how to use the Aptos SDK to send a transaction. * Don't forget to install @aptos-labs/ts-sdk before running this example! */ import { Account, Aptos, AptosConfig, Network, } from "@aptos-labs/ts-sdk"; async function example() { console.log("This example will create two accounts (Alice and Bob) and send a transaction transferring APT to Bob's account."); // 0. Setup the client and test accounts const config = new AptosConfig({ network: Network.TESTNET }); const aptos = new Aptos(config); let alice = Account.generate(); let bob = Account.generate(); console.log("=== Addresses ===\n"); console.log(`Alice's address is: ${alice.accountAddress}`); console.log(`Bob's address is: ${bob.accountAddress}`); console.log("\n=== Funding accounts ===\n"); await aptos.faucet.fundAccount({ accountAddress: alice.accountAddress, amount: 100_000_000, }); await aptos.faucet.fundAccount({ accountAddress: bob.accountAddress, amount: 100, }); console.log("Funded Alice and Bob's accounts!") // 1. Build console.log("\n=== 1. Building the transaction ===\n"); const transaction = await aptos.transaction.build.simple({ sender: alice.accountAddress, data: { // All transactions on Aptos are implemented via smart contracts. function: "0x1::aptos_account::transfer", functionArguments: [bob.accountAddress, 100], }, }); console.log("Built the transaction!") // 2. Simulate (Optional) console.log("\n === 2. Simulating Response (Optional) === \n") const [userTransactionResponse] = await aptos.transaction.simulate.simple({ signerPublicKey: alice.publicKey, transaction, }); console.log(userTransactionResponse) // 3. Sign console.log("\n=== 3. Signing transaction ===\n"); const senderAuthenticator = aptos.transaction.sign({ signer: alice, transaction, }); console.log("Signed the transaction!") // 4. Submit console.log("\n=== 4. Submitting transaction ===\n"); const submittedTransaction = await aptos.transaction.submit.simple({ transaction, senderAuthenticator, }); console.log(`Submitted transaction hash: ${submittedTransaction.hash}`); // 5. Wait for results console.log("\n=== 5. Waiting for result of transaction ===\n"); const executedTransaction = await aptos.transaction.waitForTransaction({ transactionHash: submittedTransaction.hash }); console.log(executedTransaction) }; example(); ``` -------------------------------- ### Full Transaction Lifecycle Example Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/PrivateCode.Transaction.html Demonstrates the complete process of creating two accounts, funding them, transferring APT between them, and verifying the balances. This example covers building a simple transfer transaction, signing and submitting it, and waiting for its execution. ```typescript import { Account, Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk"; const ALICE_INITIAL_BALANCE = 100_000_000; const TRANSFER_AMOUNT = 100; async function example() { console.log( "This example will create two accounts (Alice and Bob), fund them, and transfer between them.", ); // Set up the client const config = new AptosConfig({ network: Network.DEVNET }); const aptos = new Aptos(config); // Generate two account credentials // Each account has a private key, a public key, and an address const alice = Account.generate(); const bob = Account.generate(); console.log("=== Addresses ===\n"); console.log(`Alice's address is: ${alice.accountAddress}`); console.log(`Bob's address is: ${bob.accountAddress}`); // Fund the accounts using a faucet console.log("\n=== Funding accounts ===\n"); await aptos.fundAccount({ accountAddress: alice.accountAddress, amount: ALICE_INITIAL_BALANCE, }); // Check initial balance console.log("\n=== Initial Balance ===\n"); const aliceBalance = await aptos.getAccountAPTAmount({ accountAddress: alice.accountAddress, }); console.log(`Alice's balance is: ${aliceBalance}`); // Send a transaction from Alice's account to Bob's account const txn = await aptos.transaction.build.simple({ sender: alice.accountAddress, data: { // All transactions on Aptos are implemented via smart contracts. function: "0x1::aptos_account::transfer", functionArguments: [bob.accountAddress, TRANSFER_AMOUNT], }, options: { maxGasAmount: 100000 }, }); console.log("\n=== Transfer transaction ===\n"); // Both signs and submits const committedTxn = await aptos.signAndSubmitTransaction({ signer: alice, transaction: txn, }); // Waits for Aptos to verify and execute the transaction const executedTransaction = await aptos.waitForTransaction({ transactionHash: committedTxn.hash, }); console.log("Transaction hash:", executedTransaction.hash); console.log("\n=== Balances after transfer ===\n"); const newAliceBalance = await aptos.getAccountAPTAmount({ accountAddress: alice.accountAddress, }); console.log(`Alice's balance is: ${newAliceBalance}`); const newBobBalance = await aptos.getAccountAPTAmount({ accountAddress: bob.accountAddress, }); console.log(`Bob's balance is: ${newBobBalance}`); } example(); ``` -------------------------------- ### Install Aptos TS SDK with Bun Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/README.md Install the Aptos TypeScript SDK using Bun's package manager for compatibility with the Bun runtime. ```bash bun add @aptos-labs/ts-sdk ``` -------------------------------- ### Start Local Aptos Testnet Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/AGENTS.md Command to manually start a local Aptos testnet, optionally with indexer API and keyless enabled. Useful for manual testing after SDK tests have completed. ```bash TMPDIR=/tmp ENABLE_KEYLESS_DEFAULT=1 npx aptos node run-localnet --force-restart --assume-yes --with-indexer-api & ``` -------------------------------- ### Migration Example: Setting Target Address (Before) Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/upgrade-guides/UPGRADE_GUIDE_6.0.0.md Example of setting a target address in SDK v5.x, requiring separate transaction submission. ```typescript const transaction = await aptos.setTargetAddress({ sender: alice, name: "test.aptos", address: bob.accountAddress, }); await aptos.signAndSubmitTransaction({ transaction, signer: alice, }); ``` -------------------------------- ### Run Local Aptos Node Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/AGENTS.md Starts a local Aptos node using the Aptos CLI. Requires Docker. This command is used during Vitest setup. ```bash npx aptos node run-localnet --force-restart --assume-yes --with-indexer-api ``` -------------------------------- ### Install Dependencies Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/CLAUDE.md Installs project dependencies using pnpm. CI environments typically use `--frozen-lockfile` for reproducible builds. ```bash pnpm install ``` -------------------------------- ### Install and Test Confidential Asset Package Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/AGENTS.md Commands to install dependencies, navigate to the confidential asset directory, and run tests for the confidential asset package. Ensure shared infrastructure changes are compatible. ```bash pnpm install --frozen-lockfile cd confidential-asset && pnpm install --frozen-lockfile cd confidential-asset && pnpm test ``` -------------------------------- ### start Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/TransactionWorker.html Starts the transaction management process. This method initializes the worker to begin managing transactions. ```APIDOC ## start ### Description Starts the transaction management process. ### Method Signature `start(): void` ### Returns * `void` ### Throws Throws an error if the worker has already started. ### Source `src/transactions/management/transactionWorker.ts:402` ``` -------------------------------- ### Tier 1: Using the Aptos class (Convenience) Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/upgrade-guides/UPGRADE_GUIDE_7.0.0.md Example of using the main `Aptos` class for convenience. This tier is not tree-shakeable. ```typescript import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk"; const aptos = new Aptos(new AptosConfig({ network: Network.TESTNET })); await aptos.getLedgerInfo(); await aptos.account.getAccountInfo({ accountAddress: "0x1" }); ``` -------------------------------- ### Example Authentication Function String Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/types/PrivateCode.AbstractedAccountConstructorArgs.html Illustrates how to format the authentication function string using the account address. ```typescript const authenticationFunction = `${accountAddress}::permissioned_delegation::authenticate`; ``` -------------------------------- ### Importing Aptos SDK modules (CommonJS) Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/upgrade-guides/UPGRADE_GUIDE_7.0.0.md Example of how modules were imported using CommonJS `require()` syntax in previous versions. ```javascript const { Aptos, AptosConfig, Network } = require("@aptos-labs/ts-sdk"); ``` -------------------------------- ### Initialize Aptos Client with Configuration Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/PrivateCode.TransactionManagement.html Demonstrates how to initialize the Aptos client with specific network and node URL configurations. This is a foundational step for interacting with the Aptos blockchain. ```typescript 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 to use nodeUrl: "https://testnet.aptos.dev" // replace with your node URL }); // Initialize the Aptos client with the configuration const aptos = new Aptos(config); console.log("Aptos client initialized successfully."); } runExample().catch(console.error); ``` -------------------------------- ### Initialize Aptos SDK (All-in-One) Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/README.md Initialize the Aptos SDK using the all-in-one Aptos class. This method is not tree-shakeable and includes all sub-modules. ```typescript const config = new AptosConfig({ network: Network.TESTNET }); const aptos = new Aptos(config); ``` -------------------------------- ### Install Aptos TS SDK with pnpm Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/README.md Install the Aptos TypeScript SDK using pnpm for Node.js or web applications. ```bash pnpm install @aptos-labs/ts-sdk ``` -------------------------------- ### Initialize Aptos Client with Default Settings Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AptosConfig.html Shows how to instantiate the AptosConfig class with default settings, specifying only the network. This is useful for basic client initialization when no advanced configurations are needed. ```typescript import { 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); ``` -------------------------------- ### Fund Account Example Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/Aptos.html Demonstrates how to fund an account with a specified amount of tokens using the Aptos SDK. Ensure you are using a network with a public faucet like devnet. Replace the placeholder account address with your actual address. ```typescript import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk"; const config = new AptosConfig({ network: Network.DEVNET }); const aptos = new Aptos(config); async function runExample() { // Fund an account with a specified amount of tokens const transaction = await aptos.fundAccount({ accountAddress: "0x1", // replace with your account address amount: 100, }); console.log("Transaction hash:", transaction.hash); } runExample().catch(console.error); ``` -------------------------------- ### Initialize Aptos Client with Testnet Configuration Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AptosConfig.html Demonstrates how to create an AptosConfig for the testnet and initialize an Aptos client instance with it. This is a common setup for interacting with the Aptos test network. ```typescript import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk"; async function runExample() { // Create a configuration for connecting to the Aptos testnet const config = new AptosConfig({ network: Network.TESTNET }); // Initialize the Aptos client with the configuration const aptos = new Aptos(config); console.log("Aptos client initialized:", aptos); } runExample().catch(console.error); ``` -------------------------------- ### Initialize Aptos Client with Keyless Configuration Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/PrivateCode.Keyless.html Demonstrates how to initialize the Aptos client with a specific network configuration for interacting with the Aptos blockchain, particularly useful when working with Keyless features. ```typescript import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk"; async function runExample() { // Create a new configuration for the Aptos client const config = new AptosConfig({ network: Network.TESTNET }); // Specify your desired network // Initialize the Aptos client with the configuration const aptos = new Aptos(config); console.log("Aptos client initialized:", aptos); } runExample().catch(console.error); ``` -------------------------------- ### Move Struct Definition Example Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/plans/STRUCT_ENUM_SUPPORT.md Example of a Move struct definition that includes nested Option and vector types, illustrating type recursion. ```move struct Nested { inner: Option, items: vector } ``` -------------------------------- ### Example Commit Message Titles Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/CONTRIBUTING.md Examples of how to format commit message titles with an area prefix. This helps categorize changes in the commit history. ```git [ci] enforce whitelist of nightly features ``` ```git [language] removing VerificationPass trait ``` -------------------------------- ### constructor Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/PrivateCode.AptosObject.html Creates an instance of the Aptos client with the provided configuration. This allows interaction with the Aptos blockchain using the specified settings. ```APIDOC ## constructor ### Description Creates an instance of the Aptos client with the provided configuration. This allows interaction with the Aptos blockchain using the specified settings. ### Parameters #### Parameters * **config** (AptosConfig) - The configuration settings for the Aptos client. ### Returns AptosObject ### Example ```typescript 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 desired network nodeUrl: "https://testnet.aptos.dev", // Replace with your node URL }); // Create an instance of the Aptos client const aptos = new Aptos(config); console.log("Aptos client created successfully", aptos); } runExample().catch(console.error); ``` ``` -------------------------------- ### get Function Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/functions/get.html Executes a GET request to retrieve data based on the provided options. This function is a core part of interacting with the Aptos API to fetch information. ```APIDOC ## get ### Description Executes a GET request to retrieve data based on the provided options. ### Method GET ### Endpoint This function constructs an endpoint based on the `path` and `type` provided in the options. ### Parameters #### Parameters - **options** (GetRequestOptions) - Required - The options for the GET request. - **acceptType** (MimeType) - Optional - The accepted content type of the response of the API - **aptosConfig** (AptosConfig) - Required - The config for the API client - **contentType** (MimeType) - Optional - The content type of the request body - **originMethod** (string) - Required - The name of the API method - **overrides** (ClientConfig) - Optional - Specific client overrides for this request to override aptosConfig - **params** (Record) - Optional - The query parameters for the request - **path** (string) - Required - The URL path to the API method - **type** (AptosApiType) - Required - The type of API endpoint to call e.g. fullnode, indexer, etc ### Returns Promise> The response from the GET request. ``` -------------------------------- ### init Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/PrivateCode.AbstractKeylessAccount.html Initializes the asynchronous proof fetch. Emits whether the proof succeeds or fails, but has no return value. ```APIDOC ## init ### Description Initializes the asynchronous proof fetch. Emits whether the proof succeeds or fails, but has no return value. ### Method init ### Parameters * **promise** (Promise) - The promise that provides the proof. ### Returns Promise ``` -------------------------------- ### Get Account Tokens Count Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/PrivateCode.Account.html Queries the number of tokens owned by a specific account address. Use this to get a quick overview of an account's token holdings. ```typescript 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 count of tokens owned by the account const tokensCount = await aptos.getAccountTokensCount({ accountAddress: "0x1" }); // replace with a real account address console.log(`Tokens Count: ${tokensCount}`); } runExample().catch(console.error); ``` -------------------------------- ### Initialize AptosConfig with Network Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AptosConfig.html Demonstrates how to initialize AptosConfig with a specific network, such as TESTNET. This is a fundamental step before creating an Aptos instance. ```typescript import { Aptos, AptosConfig, Network, AptosApiType } from "@aptos-labs/ts-sdk"; const config = new AptosConfig({ network: Network.TESTNET }); const aptos = new Aptos(config); ``` -------------------------------- ### Using Account factory for key derivation (Recommended Replacement) Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/upgrade-guides/UPGRADE_GUIDE_7.0.0.md Illustrates the recommended way to derive accounts using the `Account.fromDerivationPath` factory method, replacing direct export of HD key utilities. ```typescript import { Account } from "@aptos-labs/ts-sdk"; const account = Account.fromDerivationPath({ path: "m/44'/637'/0'/0'/0'", mnemonic: "...", }); ``` -------------------------------- ### Configure Development Environment Variables Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/confidential-asset/tests/README.md Create a .env.development file to specify private keys for Aptos and TwistedEd25519 accounts used in testing. ```bash TESTNET_PK=your_private_key_here TESTNET_DK=your_twisted_ed25519_private_key_here ``` -------------------------------- ### y Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/interfaces/PrivateCode.CurvePoint.html Gets the y-coordinate of the CurvePoint. ```APIDOC ## y ### Description Gets the y-coordinate of the CurvePoint. ### Method Property accessor ### Parameters None ### Request Example None ### Response #### Success Response (200) Returns the y-coordinate of the CurvePoint. #### Response Example None ``` -------------------------------- ### constructor Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AccountPublicKey.html Initializes a new instance of the AccountPublicKey class. ```APIDOC ## constructor ### Description Initializes a new instance of the AccountPublicKey class. ### Method Signature `new AccountPublicKey()` ### Returns - **AccountPublicKey** ``` -------------------------------- ### Install Dependencies with Local WASM Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/confidential-asset/README.md Command to install project dependencies after updating `package.json` to use local WASM bindings. Use `--force` if local changes to the DL algorithm require it. ```bash # Use --force if you've made some local changes to the DL algorithm; otherwise the version remains the same and this does nothing pnpm install ``` -------------------------------- ### z Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/interfaces/PrivateCode.CurvePoint.html Gets the z-coordinate of the CurvePoint. ```APIDOC ## z ### Description Gets the z-coordinate of the CurvePoint. ### Method Property accessor ### Parameters None ### Request Example None ### Response #### Success Response (200) Returns the z-coordinate of the CurvePoint. #### Response Example None ``` -------------------------------- ### Initialize Aptos SDK (Standalone Functions) Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/README.md Import standalone functions from sub-paths for maximum tree-shaking, suitable for minimal bundles like wallet adapters. AptosConfig and Network can also be imported from sub-paths. ```typescript import { getLedgerInfo, AptosConfig } from "@aptos-labs/ts-sdk/general"; import { Network } from "@aptos-labs/ts-sdk"; const config = new AptosConfig({ network: Network.TESTNET }); const ledger = await getLedgerInfo({ aptosConfig: config }); ``` -------------------------------- ### x Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/interfaces/PrivateCode.CurvePoint.html Gets the x-coordinate of the CurvePoint. ```APIDOC ## x ### Description Gets the x-coordinate of the CurvePoint. ### Method Property accessor ### Parameters None ### Request Example None ### Response #### Success Response (200) Returns the x-coordinate of the CurvePoint. #### Response Example None ``` -------------------------------- ### EntryFunction Build Method Example Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/EntryFunction.html Shows the signature of a Move script function that takes type arguments and arguments, demonstrating how to map these to the parameters of the `EntryFunction.build` method. ```typescript public(script) fun transfer(from: &signer, to: address, amount: u64) ``` -------------------------------- ### constructor Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AbstractPublicKey.html Initializes a new instance of the AbstractPublicKey class. ```APIDOC ## constructor ### Description Initializes a new instance of the AbstractPublicKey class. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None * **accountAddress** ([AccountAddress](AccountAddress.html)) - Required - The account address associated with this public key. ### Request Example ```typescript const accountAddress = new AccountAddress("0x123..."); const publicKey = new AbstractPublicKey(accountAddress); ``` ### Response #### Success Response (AbstractPublicKey) Returns a new instance of AbstractPublicKey. #### Response Example ```json // Instance of AbstractPublicKey ``` ``` -------------------------------- ### signature Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AccountAuthenticatorMultiEd25519.html Gets the signature of the MultiEd25519 authenticator. ```APIDOC ## signature ### Description Represents the signature associated with the MultiEd25519 authenticator. ### Property Type MultiEd25519Signature ### Access Readonly ### Example ```typescript // Assuming 'authenticator' is an instance of AccountAuthenticatorMultiEd25519 const signature = authenticator.signature; ``` ``` -------------------------------- ### Importing Keyless and crypto utilities (v7.0.0+) Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/upgrade-guides/UPGRADE_GUIDE_7.0.0.md Demonstrates importing keyless account and crypto utilities from the dedicated `@aptos-labs/ts-sdk/keyless` sub-path in v7.0.0 and later. ```typescript import { KeylessAccount, FederatedKeylessAccount, AbstractKeylessAccount, EphemeralKeyPair, deriveKeylessAccount, getPepper, getProof, poseidonHash, hashStrToField, } from "@aptos-labs/ts-sdk/keyless"; ``` -------------------------------- ### Secp256k1Signature.toUint8Array Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/Secp256k1Signature.html Gets the raw signature bytes as a Uint8Array. ```APIDOC ## toUint8Array(): Uint8Array ### Description Get the raw signature bytes ### Returns - **Uint8Array** - The raw signature bytes. *Overrides [Signature](Signature.html).[toUint8Array](Signature.html#touint8array)* ``` -------------------------------- ### public_key Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AccountAuthenticatorMultiEd25519.html Gets the public key of the MultiEd25519 authenticator. ```APIDOC ## public_key ### Description Represents the public key associated with the MultiEd25519 authenticator. ### Property Type MultiEd25519PublicKey ### Access Readonly ### Example ```typescript // Assuming 'authenticator' is an instance of AccountAuthenticatorMultiEd25519 const publicKey = authenticator.public_key; ``` ``` -------------------------------- ### Account Constructor Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/PrivateCode.Account.html Creates an instance of the Aptos client with the provided configuration. This is the primary way to initialize the Account class for interacting with the Aptos network. ```APIDOC ## constructor ### Description Creates an instance of the Aptos client with the provided configuration. ### Parameters * **config** (AptosConfig) - The configuration settings for the Aptos client. ### Returns Account ### Example ```typescript import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk"; async function runExample() { // Initialize the Aptos client with testnet configuration const config = new AptosConfig({ network: Network.TESTNET }); // specify your own network if needed const aptos = new Aptos(config); console.log("Aptos client initialized:", aptos); } runExample().catch(console.error); ``` ``` -------------------------------- ### toUint8Array Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AbstractPublicKey.html Get the raw public key bytes. ```APIDOC ## toUint8Array() ### Description Get the raw public key bytes. ### Method * toUint8Array(): Uint8Array ### Returns - Uint8Array: The raw public key bytes. ``` -------------------------------- ### toUint8Array Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/WebAuthnSignature.html Gets the raw signature bytes of the WebAuthnSignature as a Uint8Array. ```APIDOC ## toUint8Array ### Description Gets the raw signature bytes of the WebAuthnSignature. ### Returns Uint8Array - The raw signature bytes. ``` -------------------------------- ### Publish to NPM Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/CONTRIBUTING.md Build the SDK and publish the new version to the NPM registry. This command should be run after a successful dry run and when ready to release. ```bash npm publish ``` -------------------------------- ### toString Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/WebAuthnSignature.html Gets the WebAuthnSignature as a hex string with a '0x' prefix. ```APIDOC ## toString ### Description Gets the signature as a hex string with a 0x prefix. ### Returns string - The hex string representation of the signature. ``` -------------------------------- ### Simulate Constructor Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/PrivateCode.Simulate.html Initializes a new instance of the Simulate class with the specified Aptos configuration. This client is used to interact with the Aptos blockchain for simulation purposes. ```APIDOC ## new Simulate(config: AptosConfig) ### Description 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. ### Parameters * **config** (AptosConfig) - The configuration settings for the Aptos client. ### Returns Simulate ### Example ```typescript 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 desired network // Initialize the Aptos client with the configuration const aptos = new Aptos(config); console.log("Aptos client initialized:", aptos); } runExample().catch(console.error); ``` ``` -------------------------------- ### Initialize Aptos Client Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/PrivateCode.Faucet.html Initializes a new instance of the Aptos client with the specified configuration. Only devnet has a publicly accessible faucet. ```typescript 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.DEVNET }); // 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); ``` -------------------------------- ### Secp256r1PrivateKey.length Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/Secp256r1PrivateKey.html Gets the length of the Secp256r1 private key in bytes. ```APIDOC ## length ### Description Gets the length of the Secp256r1 private key in bytes. ### Returns * **number** - The length of the private key. ``` -------------------------------- ### constructor Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/PrivateCode.DigitalAsset.html Initializes a new instance of the DigitalAsset class. ```APIDOC ## constructor ### Description Initializes a new instance of the DigitalAsset class. ### Method constructor ### Parameters This method does not take any parameters. ### Response An instance of the DigitalAsset class. ``` -------------------------------- ### Secp256k1Signature.toString Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/Secp256k1Signature.html Gets the signature as a hex string with a 0x prefix. ```APIDOC ## toString(): string ### Description Get the signature as a hex string with a 0x prefix e.g. 0x123456... ### Returns - **string** - The hex string representation of the signature. *Inherited from [Signature](Signature.html).[toString](Signature.html#tostring)* ``` -------------------------------- ### toUint8Array() Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AbstractMultiKey.html Get the raw public key bytes as a Uint8Array. ```APIDOC ## toUint8Array() ### Description Get the raw public key bytes as a Uint8Array. ### Returns - Uint8Array ``` -------------------------------- ### Submit Simple Transaction with Aptos TS SDK Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/index.html Demonstrates how to build, simulate, sign, and submit a simple Aptos transaction to transfer APT between accounts. Requires the @aptos-labs/ts-sdk package. ```typescript /** * This example shows how to use the Aptos SDK to send a transaction. * Don't forget to install @aptos-labs/ts-sdk before running this example! */ import { Account, Aptos, AptosConfig, Network, } from "@aptos-labs/ts-sdk"; async function example() { console.log("This example will create two accounts (Alice and Bob) and send a transaction transferring APT to Bob's account."); // 0. Setup the client and test accounts const config = new AptosConfig({ network: Network.TESTNET }); const aptos = new Aptos(config); let alice = Account.generate(); let bob = Account.generate(); console.log("=== Addresses ===\n"); console.log(`Alice's address is: ${alice.accountAddress}`); console.log(`Bob's address is: ${bob.accountAddress}`); console.log("\n=== Funding accounts ===\n"); await aptos.faucet.fundAccount({ accountAddress: alice.accountAddress, amount: 100_000_000, }); await aptos.faucet.fundAccount({ accountAddress: bob.accountAddress, amount: 100, }); console.log("Funded Alice and Bob's accounts!") // 1. Build console.log("\n=== 1. Building the transaction ===\n"); const transaction = await aptos.transaction.build.simple({ sender: alice.accountAddress, data: { // All transactions on Aptos are implemented via smart contracts. function: "0x1::aptos_account::transfer", functionArguments: [bob.accountAddress, 100], }, }); console.log("Built the transaction!") // 2. Simulate (Optional) console.log("\n === 2. Simulating Response (Optional) === \n") const [userTransactionResponse] = await aptos.transaction.simulate.simple({ signerPublicKey: alice.publicKey, transaction, }); console.log(userTransactionResponse) // 3. Sign console.log("\n=== 3. Signing transaction ===\n"); const senderAuthenticator = aptos.transaction.sign({ signer: alice, transaction, }); console.log("Signed the transaction!") // 4. Submit console.log("\n=== 4. Submitting transaction ===\n"); const submittedTransaction = await aptos.transaction.submit.simple({ transaction, senderAuthenticator, }); console.log(`Submitted transaction hash: ${submittedTransaction.hash}`); // 5. Wait for results console.log("\n=== 5. Waiting for result of transaction ===\n"); const executedTransaction = await aptos.transaction.waitForTransaction({ transactionHash: submittedTransaction.hash }); console.log(executedTransaction) }; example(); ``` -------------------------------- ### Run Discrete Log Benchmarks Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/confidential-asset/README.md Command to run discrete log decryption benchmarks. Set `SKIP_SETUP=1` to bypass setup steps if the environment is already prepared. ```bash SKIP_SETUP=1 pnpm test discrete ``` -------------------------------- ### authKey Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AbstractPublicKey.html Get the authentication key associated with this public key. ```APIDOC ## authKey() ### Description Get the authentication key associated with this public key. ### Method * authKey(): AuthenticationKey ### Returns - AuthenticationKey: The authentication key. ``` -------------------------------- ### Initialize Aptos SDK (Tree-Shakeable Namespaces) Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/README.md Initialize specific namespace classes from sub-paths for smaller bundles and full autocomplete. This approach is tree-shakeable. ```typescript import { Network } from "@aptos-labs/ts-sdk"; import { General, AptosConfig } from "@aptos-labs/ts-sdk/general"; import { Faucet } from "@aptos-labs/ts-sdk/faucet"; const config = new AptosConfig({ network: Network.TESTNET }); const general = new General(config); const faucet = new Faucet(config); ``` -------------------------------- ### sender Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/TransactionAuthenticatorSingleSender.html Gets the sender's account authenticator. This is a readonly property. ```APIDOC ### `Readonly` sender ### Description Gets the sender's account authenticator. ### Property Type AccountAuthenticator ### Access Readonly ``` -------------------------------- ### Secp256k1Signature.toStringWithoutPrefix Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/Secp256k1Signature.html Gets the signature as a hex string without a 0x prefix. ```APIDOC ## toStringWithoutPrefix(): string ### Description Get the signature as a hex string without a 0x prefix. ### Returns - **string** - The hex string representation of the signature without a prefix. ``` -------------------------------- ### Faucet Methods Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/Aptos.html Methods for interacting with the faucet to fund accounts with test APT. ```APIDOC ## Faucet Methods ### fundAccount Funds an account with a specified amount of test APT from the faucet. ``` -------------------------------- ### toString Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AbstractPublicKey.html Get the public key as a hex string with a 0x prefix. ```APIDOC ## toString() ### Description Get the public key as a hex string with a 0x prefix. ### Method * toString(): string ### Returns - string: The public key in hex format. ``` -------------------------------- ### toUint8Array Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/Secp256r1Signature.html Get the signature in bytes (Uint8Array). This method returns the Uint8Array representation of the signature. ```APIDOC ## toUint8Array() ### Description Get the signature in bytes (Uint8Array). ### Returns - **Uint8Array** - Uint8Array representation of the signature. ``` -------------------------------- ### Create Release Branch and Update Version Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/CONTRIBUTING.md Prepare for a new release by checking out a new branch, updating the version in package.json and CHANGELOG.md, and running the version update script. ```bash git checkout "bump_version" // update version in `package.json` // update CHANGELOG.md pnpm update-version ``` -------------------------------- ### toUint8Array() Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/MultiKeySignature.html Gets the raw signature bytes as a Uint8Array. This method is inherited from the Signature class. ```APIDOC ## toUint8Array() ### Description Get the raw signature bytes ### Returns Uint8Array ``` -------------------------------- ### Build Project Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/projects/gas-station/README.md Builds the Gas Station project using pnpm. ```bash pnpm run build ``` -------------------------------- ### BCS Encoding: Struct Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/plans/STRUCT_ENUM_SUPPORT.md Example of BCS encoding for a simple struct with two u64 fields. ```plaintext struct Point { x: u64, y: u64 } Value: { x: 10, y: 20 } BCS: [10,0,0,0,0,0,0,0, 20,0,0,0,0,0,0,0] └────── x ──────┘ └────── y ──────┘ ``` -------------------------------- ### Faucet Constructor Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/PrivateCode.Faucet.html Initializes a new instance of the Aptos client with the specified configuration. Note that only devnet has a publicly accessible faucet. For testnet, you must use the minting page at https://aptos.dev/network/faucet. ```APIDOC ## Faucet constructor ### Description Initializes a new instance of the Aptos client with the specified configuration. Note that only devnet has a publicly accessible faucet. For testnet, you must use the minting page at [https://aptos.dev/network/faucet](https://aptos.dev/network/faucet). ### Parameters #### Parameters * **config**: [AptosConfig](AptosConfig.html) The configuration settings for the Aptos client. ### Returns Faucet ### Example ```typescript 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.DEVNET }); // 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); ``` ``` -------------------------------- ### toString() Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/MultiKeySignature.html Gets the signature as a hex string with a 0x prefix. This method is inherited from the Signature class. ```APIDOC ## toString() ### Description Get the signature as a hex string with a 0x prefix e.g. 0x123456... ### Returns string - The hex string representation of the signature. ``` -------------------------------- ### Aptos Client Constructor Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/Aptos.html Initializes a new instance of the Aptos client with optional configuration settings. This is the primary entry point for interacting with the Aptos blockchain via the SDK. ```APIDOC ## constructor ### Description Initializes a new instance of the Aptos client with the provided configuration settings. ### Parameters * `config` (AptosConfig) - Optional - Configuration settings for the Aptos client. ### Returns Aptos - The initialized Aptos client instance. ``` -------------------------------- ### getTransactionSubmitter Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AptosConfig.html Gets the custom transaction submitter if one has been configured and is not ignored. Otherwise, returns undefined. ```APIDOC ## getTransactionSubmitter ### Description If a custom transaction submitter has been specified in the PluginConfig and IGNORE_TRANSACTION_SUBMITTER is false, this will return a transaction submitter that should be used instead of the default transaction submission behavior. ### Method N/A (This is a method of the AptosConfig class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Returns * **TransactionSubmitter | undefined** - The configured transaction submitter or undefined if none is set or if it's ignored. ### Example ```typescript import { AptosConfig } from "@aptos-labs/ts-sdk"; const config = new AptosConfig({}); const submitter = config.getTransactionSubmitter(); if (submitter) { console.log("Custom transaction submitter found."); } else { console.log("No custom transaction submitter found or it is ignored."); } ``` ``` -------------------------------- ### AnySignature.toString Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/AnySignature.html Gets the signature as a hexadecimal string with a '0x' prefix. This provides a human-readable representation of the signature. ```APIDOC ## toString(): string ### Description Get the signature as a hex string with a 0x prefix e.g. 0x123456... ### Returns string - The hex string representation of the signature. ### Source `src/core/crypto/signature.ts:29` ``` -------------------------------- ### Initialize Aptos Client Source: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/docs/@aptos-labs/ts-sdk-7.1.0/classes/PrivateCode.Build.html 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. ```typescript 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); ```