@aptos-labs/ts-sdk - v7.3.0
    Preparing search index...

    Class AptosConfig

    Represents the configuration settings for an Aptos SDK client instance. This class allows customization of various endpoints and client settings.

    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);
    Index

    Client

    • 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.

      Parameters

      • Optionalsettings: AptosSettings

        Optional configuration settings for the Aptos client.

        Configuration options for initializing the SDK, allowing customization of its behavior and interaction with the Aptos network.

        • Optional ReadonlyarchivalFallback?: boolean

          Whether reads of pruned history are retried against the archival endpoint the node advertises. Defaults to true.

        • Optional Readonlyclient?: Client
        • Optional ReadonlyclientConfig?: ClientConfig
        • Optional Readonlyfaucet?: string
        • Optional ReadonlyfaucetConfig?: FaucetConfig
        • Optional Readonlyfullnode?: string
        • Optional ReadonlyfullnodeConfig?: FullNodeConfig
        • Optional Readonlyindexer?: string
        • Optional ReadonlyindexerConfig?: IndexerConfig
        • Optional Readonlynetwork?: Network
        • Optional Readonlypepper?: string
        • Optional ReadonlypluginSettings?: PluginSettings
        • Optional Readonlyprover?: string
        • Optional ReadonlytransactionGenerationConfig?: TransactionGenerationConfig

      Returns AptosConfig

      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);
    archivalFallback: boolean

    Whether reads of pruned history are retried against the archival endpoint the node advertises in its 410 Gone response. Defaults to true.

    The retry happens once, only for requests that would otherwise throw. Credentials are sent to the archival endpoint only when it is on the same site as the node, since the node chooses that URL.

    client: Client

    The client instance the SDK uses. Defaults to `@aptos-labs/aptos-client

    clientConfig?: ClientConfig

    Optional client configurations

    faucet?: string

    The optional hardcoded faucet URL to send requests to instead of using the network

    faucetConfig?: FaucetConfig

    Optional specific Faucet configurations

    fullnode?: string

    The optional hardcoded fullnode URL to send requests to instead of using the network

    fullnodeConfig?: ClientHeadersType

    Optional specific Fullnode configurations

    indexer?: string

    The optional hardcoded indexer URL to send requests to instead of using the network

    indexerConfig?: ClientHeadersType

    Optional specific Indexer configurations

    network: Network

    The Network that this SDK is associated with. Defaults to DEVNET

    pepper?: string

    The optional hardcoded pepper service URL to send requests to instead of using the network

    prover?: string

    The optional hardcoded prover service URL to send requests to instead of using the network

    transactionGenerationConfig?: TransactionGenerationConfig

    Optional specific Transaction Generation configurations

    • 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.

      Parameters

      • apiType: AptosApiType

        The type of Aptos API to get the URL for. This can be one of the following: FULLNODE, FAUCET, INDEXER, PEPPER, PROVER.

      Returns string

      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.

      Parameters

      • url: string

        The URL to check against the known pepper service endpoints.

      Returns boolean

      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.

      Parameters

      • url: string

        The URL to check against known prover service endpoints.

      Returns boolean

      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}`);
    • If you have set a custom transaction submitter, you can use this to determine whether to use it or not. For example, to stop using the transaction submitter:

      Parameters

      • ignore: boolean

      Returns void

      aptos.config.setIgnoreTransactionSubmitter(true);
      

    Methods

    • 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.

      Returns TransactionSubmitter | undefined