Custom EVM client class. Extends BaseXChainClient and implements XChainClient.

Hierarchy

  • BaseXChainClient
    • Client

Implements

  • XChainClient

Constructors

Properties

chain: string
dataProviders: EvmOnlineDataProviders[]
defaults: Record<Network, EvmDefaults>
explorerProviders: ExplorerProviders
feeBounds: FeeBounds
gasAsset: Asset
gasAssetDecimals: number
hdNode?: HDNode
network: Network
phrase: string
providers: Record<Network, Provider>
rootDerivationPaths: undefined | RootDerivationPaths

Methods

  • Approves an allowance for spending tokens.

    Parameters

    Returns Promise<TransactionResponse>

    The result of the approval transaction.

    Throws

    Error If gas estimation fails.

  • Broadcasts a transaction.

    Parameters

    • txHex: string

      The transaction in hexadecimal format.

    Returns Promise<string>

    The transaction hash.

  • Call a contract function.

    Type Parameters

    • T

    Parameters

    Returns Promise<T>

    The result of the contract function call..

  • Estimates the gas required for approving an allowance.

    Parameters

    Returns Promise<BigNumber>

    The estimated gas required for the approval.

  • Estimates the gas required for calling a contract function.

    Parameters

    Returns Promise<BigNumber>

    The estimated gas required for the contract function call.

  • Estimates gas limit for a transaction.

    Parameters

    • params: TxParams & {
          from?: string;
      }

      The transaction and fees options.

    Returns Promise<BigNumber>

    The estimated gas limit.

    Throws

    Error Thrown if address could not be parsed from the given ERC20 asset.

  • Estimates gas prices (average, fast, fastest) for a transaction.

    Parameters

    • Optional protocol: THORCHAIN

      The protocol to use for estimating gas prices.

    Returns Promise<GasPrices>

    The gas prices (average, fast, fastest) in Wei (BaseAmount)

  • Parameters

    • walletIndex: number = 0

    Returns string

    Deprecated

    Use getAddressAsync instead. This function will eventually be removed.

  • Parameters

    • walletIndex: number = 0

      (optional) Index of the HD wallet.

    Returns Promise<string>

    The current address.

    Throws

    Thrown if wallet index < 0.

  • Retrieves asset information.

    Returns AssetInfo

    Asset information containing the asset and its decimal places.

  • Retrieves the balance of a given address.

    Parameters

    • address: string

      The address to retrieve the balance for.

    • Optional assets: Asset[]

      Assets to retrieve the balance for (optional).

    Returns Promise<Balance[]>

    An array containing the balance of the address.

    Throws

    Thrown when the provided asset is invalid.

  • Retrieves the explorer URL for a given address.

    Parameters

    • address: string

      The address to retrieve the explorer URL for.

    Returns string

    The explorer URL for the given address.

  • Retrieves the explorer URL for a given transaction ID.

    Parameters

    • txID: string

      The transaction ID to retrieve the explorer URL for.

    Returns string

    The explorer URL for the given transaction ID.

  • Retrieves the explorer URL based on the current network.

    Returns string

    The explorer URL for Ethereum based on the current network.

  • Get the fee rate from the Thorchain API.

    Returns Promise<number>

    The fee rate

  • Get transaction fees.

    Returns never

    The average, fast, and fastest fees.

    Throws

    Thrown if parameters are not provided.

  • Parameters

    • params: TxParams

    Returns Promise<Fees>

  • Get the full derivation path based on the wallet index.

    Parameters

    • walletIndex: number

      The HD wallet index

    Returns string

    The full derivation path

  • Get the current network.

    Returns Network

    The current network

  • Retrieves the Ethereum Provider interface.

    Returns Provider

    The current Ethereum Provider interface.

  • Retrieves the transaction details of a given transaction ID.

    Parameters

    • txId: string

      The transaction ID.

    • Optional assetAddress: string

      The asset address (optional).

    Returns Promise<Tx>

    The transaction details of the given transaction ID.

    Throws

    Thrown if the provided transaction ID is invalid.

  • Retrieves the transaction history of a given address with pagination options.

    Parameters

    • Optional params: TxHistoryParams

      Options to get transaction history (optional).

    Returns Promise<TxsPage>

    The transaction history.

  • Retrieves the Ethereum wallet interface.

    Parameters

    • walletIndex: number = 0

      The index of the HD wallet (optional).

    Returns Wallet

    The current Ethereum wallet interface.

    Throws

    Error - Thrown if the HDNode is not defined, indicating that a phrase is needed to create a wallet and derive an address. Note: A phrase is needed to create a wallet and to derive an address from it.

  • Check allowance.

    Parameters

    Returns Promise<boolean>

    true if the allowance is approved, false otherwise.

  • Checks if the given asset matches the gas asset.

    Parameters

    • asset: Asset

      The asset to check.

    Returns boolean

    True if the asset matches the gas asset, false otherwise.

  • Prepares an approval transaction.

    Parameters

    • params: ApproveParams & {
          sender: string;
      }

      The approval options.

    Returns Promise<PreparedTx>

    The raw unsigned transaction.

    Throws

    Error Thrown if any of the addresses are invalid.

  • Prepares a transaction for transfer.

    Parameters

    • params: TxParams & {
          feeOption?: FeeOption;
          gasLimit?: BigNumber;
          gasPrice?: {
              amount: (() => BigNumber);
              decimal: number;
              div: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              eq: ((value) => boolean);
              gt: ((value) => boolean);
              gte: ((value) => boolean);
              lt: ((value) => boolean);
              lte: ((value) => boolean);
              minus: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              plus: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              times: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              type: Base;
          };
          sender: string;
      }

      The transfer options.

    Returns Promise<PreparedTx>

    The raw unsigned transaction.

    Throws

    Error Thrown if the provided asset chain does not match the client's chain, or if any of the addresses are invalid.

  • Purges the client, resetting it to initial state.

    Returns void

  • Retrieves the balance of an address by round-robin querying multiple data providers.

    Parameters

    • address: string

      The address to query the balance for.

    • Optional assets: Asset[]

      Optional list of assets to query the balance for.

    Returns Promise<Balance[]>

    The balance information for the address.

    Throws

    Error Thrown if no provider is able to retrieve the balance.

  • Retrieves fee rates by round-robin querying multiple data providers.

    Returns Promise<FeeRates>

    The fee rates.

    Throws

    Error Thrown if no provider is able to retrieve the fee rates.

  • Retrieves transaction data by round-robin querying multiple data providers.

    Parameters

    • txId: string

      The transaction ID.

    • Optional assetAddress: string

      Optional asset address.

    Returns Promise<Tx>

    The transaction data.

    Throws

    Error Thrown if no provider is able to retrieve the transaction data.

  • Retrieves transaction history by round-robin querying multiple data providers.

    Parameters

    • params: TxHistoryParams

      The transaction history parameters.

    Returns Promise<TxsPage>

    The transaction history.

    Throws

    Error Thrown if no provider is able to retrieve the transaction history.

  • Sets or updates the current network.

    Parameters

    • network: Network

      The network to set or update.

    Returns void

    Throws

    Thrown if the network has not been set before.

  • Validates the given Ethereum address.

    Parameters

    • phrase: string
    • walletIndex: number = 0

    Returns string

    true if the address is valid, false otherwise.

  • Make a GET request to the Thorchain API.

    Parameters

    • endpoint: string

      The API endpoint

    Returns Promise<unknown>

    The response data

  • Transfers ETH or ERC20 token

    Note: A given feeOption wins over gasPrice and gasLimit

    Parameters

    • __namedParameters: TxParams & {
          feeOption?: FeeOption;
          gasLimit?: BigNumber;
          gasPrice?: {
              amount: (() => BigNumber);
              decimal: number;
              div: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              eq: ((value) => boolean);
              gt: ((value) => boolean);
              gte: ((value) => boolean);
              lt: ((value) => boolean);
              lte: ((value) => boolean);
              minus: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              plus: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              times: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              type: Base;
          };
          maxFeePerGas?: {
              amount: (() => BigNumber);
              decimal: number;
              div: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              eq: ((value) => boolean);
              gt: ((value) => boolean);
              gte: ((value) => boolean);
              lt: ((value) => boolean);
              lte: ((value) => boolean);
              minus: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              plus: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              times: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              type: Base;
          };
          maxPriorityFeePerGas?: {
              amount: (() => BigNumber);
              decimal: number;
              div: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              eq: ((value) => boolean);
              gt: ((value) => boolean);
              gte: ((value) => boolean);
              lt: ((value) => boolean);
              lte: ((value) => boolean);
              minus: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              plus: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              times: ((value, decimal?) => { type: Denomination.Base; amount: () => BigNumber; plus: (value: ... | Value, decimal?: number | undefined) => ...; minus: (value: ... | Value, decimal?: number | undefined) => ...; ... 7 more ...; decimal: number; });
              type: Base;
          };
          signer?: Signer;
      }

    Returns Promise<string>

    The transaction hash.

    Throws

    Error Thrown if address of given Asset could not be parsed

  • Validate the given address.

    Parameters

    • address: string

    Returns boolean

    true or false

Generated using TypeDoc