BaseWalletUnlocked provides the base functionalities for an unlocked wallet.

Hierarchy (view full)

Constructors

Properties

_connector?: FuelConnector

The connector for use with external wallets

_provider?: Provider

The provider used to interact with the network.

The address associated with the account.

signer: (() => Signer)

A function that returns the wallet's signer.

defaultPath: string = "m/44'/1179993420'/0'/0/0"

Default HDWallet path.

Accessors

  • get privateKey(): string
  • Gets the private key of the wallet.

    Returns string

    The private key of the wallet.

  • get provider(): Provider
  • The provider used to interact with the network.

    Returns Provider

    A Provider instance.

    FuelError if the provider is not set.

  • set provider(provider): void
  • Sets the provider for the account.

    Parameters

    Returns void

  • get publicKey(): string
  • Gets the public key of the wallet.

    Returns string

Methods

  • Transfers multiple amounts of a token to multiple recipients.

    Parameters

    • transferParams: TransferParams[]

      An array of TransferParams objects representing the transfers to be made.

    • txParams: TxParamsType = {}

      Optional transaction parameters.

    Returns Promise<TransactionResponse>

    A promise that resolves to a TransactionResponse object representing the transaction result.

  • Changes the provider connection for the account.

    Parameters

    Returns Provider

    The updated Provider instance.

  • A helper that creates a transfer transaction request and returns it.

    Parameters

    • destination: string | AbstractAddress

      The address of the destination.

    • amount: BigNumberish

      The amount of coins to transfer.

    • OptionalassetId: BytesLike

      The asset ID of the coins to transfer (optional).

    • txParams: TxParamsType = {}

      The transaction parameters (optional).

    Returns Promise<ScriptTransactionRequest>

    A promise that resolves to the prepared transaction request.

  • Encrypts an unlocked wallet with a password.

    Parameters

    • password: string

      the password to encrypt the wallet with.

    Returns Promise<string>

    • the encrypted wallet.
  • Funds a transaction request by adding the necessary resources.

    Type Parameters

    Parameters

    • request: T

      The transaction request to fund.

    • params: EstimatedTxParams

      The estimated transaction parameters.

    Returns Promise<T>

    A promise that resolves to the funded transaction request.

  • Generates an array of fake resources based on the provided coins.

    Parameters

    • coins: FakeResources[]

      An array of FakeResources objects representing the coins.

    Returns Resource[]

    An array of Resource objects with generated properties.

  • Retrieves the balance of the account for the given asset.

    Parameters

    • OptionalassetId: BytesLike

      The asset ID to check the balance for (optional).

    Returns Promise<BN>

    A promise that resolves to the balance amount.

  • Retrieves coins owned by the account.

    Parameters

    • OptionalassetId: BytesLike

      The asset ID of the coins to retrieve (optional).

    • OptionalpaginationArgs: CursorPaginationArgs

    Returns Promise<GetCoinsResponse>

    A promise that resolves to an array of Coins.

  • Retrieves messages owned by the account.

    Parameters

    • OptionalpaginationArgs: CursorPaginationArgs

    Returns Promise<GetMessagesResponse>

    A promise that resolves to an array of Messages.

  • Retrieves resources satisfying the spend query for the account.

    Parameters

    • quantities: CoinQuantityLike[]

      Quantities of resources to be obtained.

    • OptionalexcludedIds: ExcludeResourcesOption

      IDs of resources to be excluded from the query (optional).

    Returns Promise<Resource[]>

    A promise that resolves to an array of Resources.

  • Returns a transaction cost to enable user to set gasLimit and also reserve balance amounts on the transaction.

    Parameters

    Returns Promise<TransactionCost>

    A promise that resolves to the transaction cost object.

  • Populates a transaction with the witnesses signature.

    Type Parameters

    Parameters

    Returns Promise<T>

    The populated transaction request.

  • Populates the witness signature for a transaction and sends it to the network using provider.sendTransaction.

    Parameters

    Returns Promise<TransactionResponse>

    A promise that resolves to the TransactionResponse object.

  • Signs a message with the wallet's private key.

    Parameters

    • message: string

      The message to sign.

    Returns Promise<string>

    A promise that resolves to the signature as a ECDSA 64 bytes string.

  • Signs a transaction with the wallet's private key.

    Parameters

    Returns Promise<string>

    A promise that resolves to the signature as a ECDSA 64 bytes string.

  • Populates the witness signature for a transaction and sends a call to the network using provider.dryRun.

    Parameters

    Returns Promise<CallResult>

    A promise that resolves to the CallResult object.

  • Transfers coins to a destination address.

    Parameters

    • destination: string | AbstractAddress

      The address of the destination.

    • amount: BigNumberish

      The amount of coins to transfer.

    • OptionalassetId: BytesLike

      The asset ID of the coins to transfer (optional).

    • txParams: TxParamsType = {}

      The transaction parameters (optional).

    Returns Promise<TransactionResponse>

    A promise that resolves to the transaction response.

  • Transfers coins to a contract address.

    Parameters

    • contractId: string | AbstractAddress

      The address of the contract.

    • amount: BigNumberish

      The amount of coins to transfer.

    • assetId: BytesLike

      The asset ID of the coins to transfer (optional).

    • txParams: TxParamsType = {}

      The transaction parameters (optional).

    Returns Promise<TransactionResponse>

    A promise that resolves to the transaction response.