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

    Class Faucet

    The Faucet class provides methods for funding accounts 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 Faucet

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

      const supra = new SupraClient({ network: Network.TESTNET });
    • Fund an account with the node's faucet. The request is sent on any network; a node that does not serve the faucet answers with an error status, which is thrown as a SupraAPIError. The faucet answers before its transaction executes: pass the returned hash to supra.transaction.waitForTransaction before spending the funds.

      Parameters

      Returns Promise<FaucetTransactionResponse>

      A Promise that resolves to a FaucetTransactionResponse object, the hash of the faucet transaction.

      SupraFaucetUnavailableError when the node has no free faucet account (answer "TryLater").

      SupraFaucetResponseError when the node answers with an unexpected body.

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

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

      async function runExample() {
      const accountAddress = "0x1";
      const faucetResponse = await supra.faucet.fundAccountWithFaucet({ accountAddress: accountAddress });
      console.log(faucetResponse);
      }

      runExample().catch(console.error);
    • Read a faucet transaction by its hash.

      Parameters

      • args: { transactionHash: string }
        • transactionHash: string

          The hash returned by fundAccountWithFaucet.

      Returns Promise<SupraTransactionResponse>

      A Promise that resolves to the faucet transaction.

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

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

      async function runExample() {
      const { hash } = await supra.faucet.fundAccountWithFaucet({ accountAddress: "0x1" });
      const transaction = await supra.faucet.getFaucetTransaction({ transactionHash: hash });
      console.log(transaction.status);
      }

      runExample().catch(console.error);