supra-ts-sdk - v2.0.0
    Preparing search index...

    Class Events

    The Events class provides methods for fetching events on the Supra network.

    Hierarchy (View Summary)

    Index
    • The constructor function takes a NetworkConfig object as a parameter and assigns it to the networkInformation property.

      Parameters

      • networkInformation: NetworkConfig

        A NetworkConfig object that contains information about the network on which the Supra client is running.

      Returns Events

      import { SupraClient,Network } from "supra-ts-sdk";

      const supra = new SupraClient({ network: Network.TESTNET });
    • Get the events of the given type.

      SUPRA deposits are 0x1::coin::CoinDeposit events (field account) where SUPRA is held in a CoinStore, and 0x1::fungible_asset::Deposit events (field store, the fungible store, not the account) where it is held in a primary fungible store.

      Parameters

      • args: {
            eventType: `${string}::${string}::${string}`;
            options: {
                startHeight?: number;
                endHeight?: number;
                limit?: number;
                start?: string;
            };
        }
        • eventType: `${string}::${string}::${string}`

          Type of event

        • options: { startHeight?: number; endHeight?: number; limit?: number; start?: string }

          The options object is required and can be empty.

          • OptionalstartHeight?: number

            Starting block height (inclusive)

          • OptionalendHeight?: number

            Ending block height (exclusive)

          • Optionallimit?: number

            Maximum number of events to return. Defaults to 20, max 100.

          • Optionalstart?: string

            The cursor of the previous page, a hex string. Omit it, or pass undefined, for the first page.

      Returns Promise<PaginatedResponse<Event[]>>

      A Promise that resolves to an array of events, with the cursor of the next page. cursor is undefined when there are no more events; a page can hold fewer than limit events and still carry a cursor. See PaginatedResponse.

      HTTP 410 when the requested heights have been pruned from the node.

      import { SupraClient,Network } from "supra-ts-sdk";

      const supra = new SupraClient({ network: Network.TESTNET });

      async function runExample() {
      const eventType = "0x1::coin::CoinDeposit";
      const {response: events, cursor} = await supra.events.getEventsByType({ eventType: eventType, options: {} });
      console.log(events);
      }

      runExample().catch(console.error);