@aptos-labs/ts-sdk - v5.1.4
    Preparing search index...

    Class Staking

    A class to query all Staking related queries on Aptos.

    Hierarchy (View Summary)

    Index

    Properties

    config: AptosConfig

    The configuration settings for the Aptos client.

    Staking

    • Creates an 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 Staking

      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 network

      // Initialize the Aptos client with the configuration
      const aptos = new Aptos(config);

      console.log("Aptos client initialized:", aptos);
      }
      runExample().catch(console.error);
    • Queries delegated staking activities for a specific delegator and pool.

      Parameters

      Returns Promise<
          {
              amount: any;
              delegator_address: string;
              event_index: any;
              event_type: string;
              pool_address: string;
              transaction_version: any;
          }[],
      >

      The response containing delegated staking activities.

      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 delegated staking activities for a specific delegator and pool
      const activities = await aptos.getDelegatedStakingActivities({
      delegatorAddress: "0x1", // replace with a real delegator address
      poolAddress: "0x2", // replace with a real pool address
      minimumLedgerVersion: 1, // specify your own if needed
      });

      console.log(activities);
      }
      runExample().catch(console.error);
    • Queries the current number of delegators in a specified pool. Throws an error if the pool is not found.

      Parameters

      Returns Promise<number>

      The number of delegators for the given pool.

      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 number of delegators for a specific pool
      const delegators = await aptos.getNumberOfDelegators({ poolAddress: "0x1" }); // replace with a real pool address
      console.log(`Number of delegators: ${delegators}`);
      }
      runExample().catch(console.error);
    • Retrieves the current number of delegators across all pools.

      Parameters

      • Optionalargs: {
            minimumLedgerVersion?: AnyNumber;
            options?: OrderByArg<
                { num_active_delegator?: any; pool_address?: null
                | string },
            >;
        }

        Optional parameters for the query.

        • OptionalminimumLedgerVersion?: AnyNumber

          Optional ledger version to sync up to before querying.

        • Optionaloptions?: OrderByArg<{ num_active_delegator?: any; pool_address?: null | string }>

          Optional ordering options for the response.

      Returns Promise<{ num_active_delegator?: any; pool_address?: null | string }[]>

      GetNumberOfDelegatorsForAllPoolsResponse response type containing the number of delegators per pool.

      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 the number of delegators for all pools
      const delegators = await aptos.getNumberOfDelegatorsForAllPools();
      console.log(delegators);
      }
      runExample().catch(console.error);