A class to query all Event Aptos related queries.

Hierarchy (View Summary)

Event

  • Initializes a new instance of the Aptos client with the provided configuration.

    Parameters

    • config: AptosConfig

      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.

      • constructor:function
        • 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.

            • 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 Readonlyprover?: string

          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);
      • Readonlyclient: Client

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

      • Optional ReadonlyclientConfig?: ClientConfig

        Optional client configurations

      • Optional Readonlyfaucet?: string

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

      • Optional ReadonlyfaucetConfig?: FaucetConfig

        Optional specific Faucet configurations

      • Optional Readonlyfullnode?: string

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

      • Optional ReadonlyfullnodeConfig?: ClientHeadersType

        Optional specific Fullnode configurations

      • Optional Readonlyindexer?: string

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

      • Optional ReadonlyindexerConfig?: ClientHeadersType

        Optional specific Indexer configurations

      • Readonlynetwork: Network

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

      • Optional Readonlypepper?: string

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

      • Optional Readonlyprover?: string

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

      • getRequestUrl:function
        • 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);
      • isPepperServiceRequest:function
        • 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);
      • isProverServiceRequest:function
        • 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}`);

    Returns Event

    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 }); // Specify your own network if needed
    const aptos = new Aptos(config);

    console.log("Aptos client initialized:", aptos);
    }
    runExample().catch(console.error);
  • Retrieve events associated with a specific account address and creation number.

    Parameters

    • args: {
          accountAddress: AccountAddressInput;
          creationNumber: AnyNumber;
          minimumLedgerVersion?: AnyNumber;
      }

      The parameters for retrieving account events.

      • accountAddress: AccountAddressInput

        The account address to query events for.

      • creationNumber: AnyNumber

        The event creation number to filter the events.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional minimum ledger version to sync up to before querying.

    Returns Promise<
        {
            account_address: string;
            creation_number: any;
            data: any;
            event_index: any;
            indexed_type: string;
            sequence_number: any;
            transaction_block_height: any;
            transaction_version: any;
            type: string;
        }[],
    >

    Promise

    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 events for the account at creation number 0
    const events = await aptos.getAccountEventsByCreationNumber({
    accountAddress: "0x1", // replace with a real account address
    creationNumber: 0,
    });

    console.log(events);
    }
    runExample().catch(console.error);
  • Retrieve events associated with a specific account address and event type.

    Parameters

    • args: {
          accountAddress: AccountAddressInput;
          eventType: `${string}::${string}::${string}`;
          minimumLedgerVersion?: AnyNumber;
          options?: PaginationArgs & OrderByArg<
              {
                  account_address: string;
                  creation_number: any;
                  data: any;
                  event_index: any;
                  indexed_type: string;
                  sequence_number: any;
                  transaction_block_height: any;
                  transaction_version: any;
                  type: string;
              },
          >;
      }
      • accountAddress: AccountAddressInput

        The account address to query events for.

      • eventType: `${string}::${string}::${string}`

        The type of event to filter by.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: PaginationArgs & OrderByArg<
            {
                account_address: string;
                creation_number: any;
                data: any;
                event_index: any;
                indexed_type: string;
                sequence_number: any;
                transaction_block_height: any;
                transaction_version: any;
                type: string;
            },
        >

        Optional pagination and ordering parameters for the event query.

    Returns Promise<
        {
            account_address: string;
            creation_number: any;
            data: any;
            event_index: any;
            indexed_type: string;
            sequence_number: any;
            transaction_block_height: any;
            transaction_version: any;
            type: string;
        }[],
    >

    Promise

    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 events for a specific account and event type
    const events = await aptos.getAccountEventsByEventType({
    accountAddress: "0x1", // replace with a real account address
    eventType: "0x1::transaction_fee::FeeStatement", // replace with a real event type
    minimumLedgerVersion: 1, // optional, specify if needed
    });

    console.log(events);
    }
    runExample().catch(console.error);
  • Retrieve all events from the Aptos blockchain. An optional where clause can be provided to filter the results based on specific criteria.

    Parameters

    • Optionalargs: {
          minimumLedgerVersion?: AnyNumber;
          options?: PaginationArgs & OrderByArg<
              {
                  account_address: string;
                  creation_number: any;
                  data: any;
                  event_index: any;
                  indexed_type: string;
                  sequence_number: any;
                  transaction_block_height: any;
                  transaction_version: any;
                  type: string;
              },
          > & WhereArg<EventsBoolExp>;
      }

      Optional parameters for the query.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: PaginationArgs & OrderByArg<
            {
                account_address: string;
                creation_number: any;
                data: any;
                event_index: any;
                indexed_type: string;
                sequence_number: any;
                transaction_block_height: any;
                transaction_version: any;
                type: string;
            },
        > & WhereArg<EventsBoolExp>

        Optional pagination and filtering options.

    Returns Promise<
        {
            account_address: string;
            creation_number: any;
            data: any;
            event_index: any;
            indexed_type: string;
            sequence_number: any;
            transaction_block_height: any;
            transaction_version: any;
            type: string;
        }[],
    >

    GetEventsQuery response type containing the events.

    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 all events
    const events = await aptos.getEvents();

    // Retrieve events with filtering by account address
    const whereCondition = {
    account_address: { _eq: "0x123" }, // replace with a real account address
    };
    const filteredEvents = await aptos.getEvents({
    options: { where: whereCondition },
    });

    console.log(events);
    console.log(filteredEvents);
    }
    runExample().catch(console.error);
  • Retrieve module events based on a specified event type. This function allows you to query for events that are associated with a particular module event type in the Aptos blockchain.

    Parameters

    • args: {
          eventType: `${string}::${string}::${string}`;
          minimumLedgerVersion?: AnyNumber;
          options?: PaginationArgs & OrderByArg<
              {
                  account_address: string;
                  creation_number: any;
                  data: any;
                  event_index: any;
                  indexed_type: string;
                  sequence_number: any;
                  transaction_block_height: any;
                  transaction_version: any;
                  type: string;
              },
          >;
      }

      The arguments for retrieving module events.

      • eventType: `${string}::${string}::${string}`

        The event type to filter the results.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: PaginationArgs & OrderByArg<
            {
                account_address: string;
                creation_number: any;
                data: any;
                event_index: any;
                indexed_type: string;
                sequence_number: any;
                transaction_block_height: any;
                transaction_version: any;
                type: string;
            },
        >

        Optional pagination and ordering parameters for the event results.

    Returns Promise<
        {
            account_address: string;
            creation_number: any;
            data: any;
            event_index: any;
            indexed_type: string;
            sequence_number: any;
            transaction_block_height: any;
            transaction_version: any;
            type: string;
        }[],
    >

    Promise - A promise that resolves to the retrieved events.

    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 module events for a specific event type
    const events = await aptos.getModuleEventsByEventType({
    eventType: "0x1::transaction_fee::FeeStatement", // specify the event type
    minimumLedgerVersion: 1, // optional: specify minimum ledger version if needed
    });

    console.log(events); // log the retrieved events
    }
    runExample().catch(console.error);

Properties

config: AptosConfig

The configuration settings for the Aptos client.

MMNEPVFCICPMFPCPTTAAATR