Class FaucetClient

Class for requsting tokens from faucet

Hierarchy

Constructors

Properties

faucetRequester: AxiosHttpRequest
nodeUrl: string

Methods

  • This creates an account if it does not exist and mints the specified amount of coins into that account

    Returns

    Hashes of submitted transactions

    Parameters

    • address: MaybeHexString

      Hex-encoded 16 bytes Aptos account address wich mints tokens

    • amount: number

      Amount of tokens to mint

    • timeoutSecs: number = DEFAULT_TXN_TIMEOUT_SEC

    Returns Promise<string[]>

  • Queries an Aptos account by address

    Returns

    Core account resource, used for identifying account and transaction execution

    Example

    An example of the returned account

    {
    sequence_number: "1",
    authentication_key: "0x5307b5f4bc67829097a8ba9b43dba3b88261eeccd1f709d9bde240fc100fbb69"
    }

    Parameters

    • accountAddress: MaybeHexString

      Hex-encoded 32 byte Aptos account address

    Returns Promise<AccountData>

  • Queries module associated with given account by module name

    Note: In order to get all account resources, this function may call the API multiple times as it paginates.

    Returns

    Specified module. Module is represented by MoveModule interface. It contains module bytecode and abi, which JSON representation of a module

    Parameters

    • accountAddress: MaybeHexString

      Hex-encoded 32 byte Aptos account address

    • moduleName: string

      The name of the module

    • Optional query: {
          ledgerVersion?: AnyNumber;
      }
      • Optional ledgerVersion?: AnyNumber

        Specifies ledger version of transactions. By default latest version will be used

    Returns Promise<MoveModuleBytecode>

  • Queries modules associated with given account

    Note: In order to get all account modules, this function may call the API multiple times as it paginates.

    Returns

    Account modules array for a specific ledger version. Module is represented by MoveModule interface. It contains module bytecode and abi, which is JSON representation of a module

    Parameters

    • accountAddress: MaybeHexString

      Hex-encoded 32 byte Aptos account address

    • Optional query: {
          ledgerVersion?: AnyNumber;
      }
      • Optional ledgerVersion?: AnyNumber

        Specifies ledger version of transactions. By default latest version will be used

    Returns Promise<MoveModuleBytecode[]>

  • Queries resource associated with given account by resource type

    Returns

    Account resource of specified type and ledger version

    Example

    An example of an account resource

    {
    type: "0x1::aptos_coin::AptosCoin",
    data: { value: 6 }
    }

    Parameters

    • accountAddress: MaybeHexString

      Hex-encoded 32 byte Aptos account address

    • resourceType: string

      String representation of an on-chain Move struct type

    • Optional query: {
          ledgerVersion?: AnyNumber;
      }
      • Optional ledgerVersion?: AnyNumber

        Specifies ledger version of transactions. By default latest version will be used

    Returns Promise<MoveResource>

  • Get block by height

    Returns

    Block

    Parameters

    • blockHeight: number

      Block height to lookup. Starts at 0

    • Optional withTransactions: boolean

      If set to true, include all transactions in the block

    Returns Promise<Block>

  • Get block by block transaction version

    Returns

    Block

    Parameters

    • version: number

      Ledger version to lookup block information for

    • Optional withTransactions: boolean

      If set to true, include all transactions in the block

    Returns Promise<Block>

  • Event types are globally identifiable by an account address and monotonically increasing creation_number, one per event type emitted to the given account. This API returns events corresponding to that that event type.

    Returns

    Array of events assotiated with the given account and creation number.

    Parameters

    • address: MaybeHexString

      Hex-encoded 32 byte Aptos account, with or without a 0x prefix, for which events are queried. This refers to the account that events were emitted to, not the account hosting the move module that emits that event type.

    • creationNumber: string | AnyNumber

      Creation number corresponding to the event type.

    • Optional query: PaginationArgs

    Returns Promise<Event[]>

  • This API uses the given account address, eventHandle, and fieldName to build a key that can globally identify an event types. It then uses this key to return events emitted to the given account matching that event type.

    Returns

    Array of events

    Parameters

    • address: MaybeHexString

      Hex-encoded 32 byte Aptos account, with or without a 0x prefix, for which events are queried. This refers to the account that events were emitted to, not the account hosting the move module that emits that event type.

    • eventHandleStruct: string

      String representation of an on-chain Move struct type. (e.g. 0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>)

    • fieldName: string

      The field name of the EventHandle in the struct

    • Optional query: PaginationArgs

      Optional query object

    Returns Promise<Event[]>

  • Gets a table item for a table identified by the handle and the key for the item. Key and value types need to be passed in to help with key serialization and value deserialization.

    Returns

    Table item value rendered in JSON

    Parameters

    • handle: string

      A pointer to where that table is stored

    • data: TableItemRequest

      Object, that describes table item

    • Optional query: {
          ledgerVersion?: AnyNumber;
      }

    Returns Promise<any>

  • Converts a transaction request produced by generateTransaction into a properly signed transaction, which can then be submitted to the blockchain

    Returns

    A transaction, signed with sender account

    Parameters

    • accountFrom: AptosAccount

      AptosAccount of transaction sender

    • rawTransaction: RawTransaction

      A raw transaction generated by generateTransaction method

    Returns Promise<Uint8Array>

  • Generates and submits a transaction to the transaction simulation endpoint. For this we generate a transaction with a fake signature.

    Returns

    The BCS encoded signed transaction, which you should then provide

    Parameters

    • accountOrPubkey: Ed25519PublicKey | MultiEd25519PublicKey | AptosAccount

      The sender or sender's public key. When private key is available, AptosAccount instance can be used to send the transaction for simulation. If private key is not available, sender's public key can be used to send the transaction for simulation.

    • rawTransaction: RawTransaction

      The raw transaction to be simulated, likely created by calling the generateTransaction function.

    • Optional query: {
          estimateGasUnitPrice?: boolean;
          estimateMaxGasAmount?: boolean;
          estimatePrioritizedGasUnitPrice: boolean;
      }
      • Optional estimateGasUnitPrice?: boolean

        If set to true, the gas unit price in the transaction will be ignored and the estimated value will be used.

      • Optional estimateMaxGasAmount?: boolean

        If set to true, the max gas value in the transaction will be ignored and the maximum possible gas will be used.

      • estimatePrioritizedGasUnitPrice: boolean

        If set to true, the transaction will use a higher price than the original estimate.

    Returns Promise<Types.UserTransaction[]>

  • Submits the BCS serialization of a signed transaction to the simulation endpoint.

    Returns

    Simulation result in the form of UserTransaction.

    Parameters

    • bcsBody: Uint8Array

      The output of generateBCSSimulation.

    • Optional query: {
          estimateGasUnitPrice?: boolean;
          estimateMaxGasAmount?: boolean;
          estimatePrioritizedGasUnitPrice?: boolean;
      }
      • Optional estimateGasUnitPrice?: boolean
      • Optional estimateMaxGasAmount?: boolean
      • Optional estimatePrioritizedGasUnitPrice?: boolean

    Returns Promise<Types.UserTransaction[]>

  • Defines if specified transaction is currently in pending state

    Returns

    true if transaction is in pending state and false otherwise

    Parameters

    • txnHash: string

      A hash of transaction

      To create a transaction hash:

      1. Create hash message bytes: "Aptos::Transaction" bytes + BCS bytes of Transaction.
      2. Apply hash algorithm SHA3-256 to the hash message bytes.
      3. Hex-encode the hash bytes with 0x prefix.

    Returns Promise<boolean>

  • This function works the same as waitForTransactionWithResult except it doesn't return the transaction in those cases, it returns nothing. For more information, see the documentation for waitForTransactionWithResult.

    Parameters

    • txnHash: string
    • Optional extraArgs: {
          checkSuccess?: boolean;
          timeoutSecs?: number;
      }
      • Optional checkSuccess?: boolean
      • Optional timeoutSecs?: number

    Returns Promise<void>

  • Wait for a transaction to move past pending state.

    There are 4 possible outcomes:

    1. Transaction is processed and successfully committed to the blockchain.
    2. Transaction is rejected for some reason, and is therefore not committed to the blockchain.
    3. Transaction is committed but execution failed, meaning no changes were written to the blockchain state.
    4. Transaction is not processed within the specified timeout.

    In case 1, this function resolves with the transaction response returned by the API.

    In case 2, the function will throw an ApiError, likely with an HTTP status code indicating some problem with the request (e.g. 400).

    In case 3, if checkSuccess is false (the default), this function returns the transaction response just like in case 1, in which the success field will be false. If checkSuccess is true, it will instead throw a FailedTransactionError.

    In case 4, this function throws a WaitForTransactionError.

    Returns

    See above.

    Example

    const rawTransaction = await this.generateRawTransaction(sender.address(), payload, extraArgs);
    const bcsTxn = AptosClient.generateBCSTransaction(sender, rawTransaction);
    const pendingTransaction = await this.submitSignedBCSTransaction(bcsTxn);
    const transasction = await this.aptosClient.waitForTransactionWithResult(pendingTransaction.hash);

    Parameters

    • txnHash: string

      The hash of a transaction previously submitted to the blockchain.

    • Optional extraArgs: {
          checkSuccess?: boolean;
          timeoutSecs?: number;
      }
      • Optional checkSuccess?: boolean

        See above. Defaults to false.

      • Optional timeoutSecs?: number

        Timeout in seconds. Defaults to 20 seconds.

    Returns Promise<Types.Transaction>

  • Note: Unless you have a specific reason for using this, it'll probably be simpler to use simulateTransaction.

    Generates a BCS transaction that can be submitted to the chain for simulation.

    Returns

    The BCS encoded signed transaction, which you should then pass into the submitBCSSimulation function.

    Parameters

    • accountFrom: AptosAccount

      The account that will be used to send the transaction for simulation.

    • rawTxn: RawTransaction

      The raw transaction to be simulated, likely created by calling the generateTransaction function.

    Returns Uint8Array

Generated using TypeDoc