API Reference

Complete API documentation for @tetherto/wdk-wallet-evm

Table of Contents

Class
Description
Methods

Main class for managing EVM wallets. Extends WalletManager from @tetherto/wdk-wallet.

Individual EVM wallet account implementation. Extends WalletAccountReadOnlyEvm and implements IWalletAccount from @tetherto/wdk-wallet.

Read-only EVM wallet account. Extends WalletAccountReadOnly from @tetherto/wdk-wallet.

WalletManagerEvm

The main class for managing EVM wallets. Extends WalletManager from @tetherto/wdk-wallet.

Fee Rate Constants

export const FEE_RATE_NORMAL_MULTIPLIER = 1.1
export const FEE_RATE_FAST_MULTIPLIER = 2.0

Constructor

new WalletManagerEvm(seed, config?)

Parameters:

  • seed (string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytes

  • config (object, optional): Configuration object

    • provider (string | Eip1193Provider, optional): RPC endpoint URL or EIP-1193 provider instance

    • transferMaxFee (number, optional): Maximum fee amount for transfer operations (in wei)

Example:

Methods

Method
Description
Returns
Throws

getAccount(index?)

Returns a wallet account at the specified index

Promise<WalletAccountEvm>

-

getAccountByPath(path)

Returns a wallet account at the specified BIP-44 derivation path

Promise<WalletAccountEvm>

-

getFeeRates()

Returns current fee rates for transactions

Promise<{normal: number, fast: number}>

If no provider is set

dispose()

Disposes all wallet accounts, clearing private keys from memory

void

-

getAccount(index?)

Returns a wallet account at the specified index following BIP-44 standard.

Parameters:

  • index (number, optional): The index of the account to get (default: 0)

Returns: Promise<WalletAccountEvm> - The wallet account

Example:

getAccountByPath(path)

Returns a wallet account at the specified BIP-44 derivation path.

Parameters:

  • path (string): The derivation path (e.g., "0'/0/0")

Returns: Promise<WalletAccountEvm> - The wallet account

Example:

getFeeRates()

Returns current fee rates based on network conditions with predefined multipliers.

Returns: Promise<{normal: number, fast: number}> - Fee rates in wei

  • normal: Base fee × 1.1 (10% above base)

  • fast: Base fee × 2.0 (100% above base)

Throws: Error if no provider is configured

Example:

dispose()

Disposes all wallet accounts, clearing private keys from memory.

Example:

WalletAccountEvm

Represents an individual wallet account. Implements IWalletAccount from @tetherto/wdk-wallet.

Constants

Constructor

Parameters:

  • seed (string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytes

  • path (string): BIP-44 derivation path (e.g., "0'/0/0")

  • config (object, optional): Configuration object

    • provider (string | Eip1193Provider, optional): RPC endpoint URL or EIP-1193 provider instance

    • transferMaxFee (number, optional): Maximum fee amount for transfer operations (in wei)

Throws:

  • Error if seed phrase is invalid (BIP-39 validation fails)

Example:

Methods

Method
Description
Returns
Throws

getAddress()

Returns the account's address

Promise<string>

-

sign(message)

Signs a message using the account's private key

Promise<string>

-

verify(message, signature)

Verifies a message signature

Promise<boolean>

-

sendTransaction(tx)

Sends an EVM transaction

Promise<{hash: string, fee: number}>

If no provider

quoteSendTransaction(tx)

Estimates the fee for an EVM transaction

Promise<{fee: number}>

If no provider

transfer(options)

Transfers ERC20 tokens to another address

Promise<{hash: string, fee: number}>

If no provider or fee exceeds max

quoteTransfer(options)

Estimates the fee for an ERC20 transfer

Promise<{fee: number}>

If no provider

getBalance()

Returns the native token balance (in wei)

Promise<number>

If no provider

getTokenBalance(tokenAddress)

Returns the balance of a specific ERC20 token

Promise<number>

If no provider

toReadOnlyAccount()

Returns a read-only copy of the account

Promise<WalletAccountReadOnlyEvm>

-

dispose()

Disposes the wallet account, clearing private keys from memory

void

-

getAddress()

Returns the account's Ethereum address.

Returns: Promise<string> - Checksummed Ethereum address

Example:

sign(message)

Signs a message using the account's private key.

Parameters:

  • message (string): The message to sign

Returns: Promise<string> - The message signature

Example:

verify(message, signature)

Verifies a message signature against the account's address.

Parameters:

  • message (string): The original message

  • signature (string): The signature to verify

Returns: Promise<boolean> - True if signature is valid

Example:

sendTransaction(tx)

Sends an EVM transaction and returns the result with hash and fee.

Parameters:

  • tx (EvmTransaction): The transaction object

    • to (string): Recipient address

    • value (number): Amount in wei

    • data (string, optional): Transaction data in hex format

    • gasLimit (number, optional): Maximum gas units

    • gasPrice (number, optional): Legacy gas price in wei

    • maxFeePerGas (number, optional): EIP-1559 max fee per gas in wei

    • maxPriorityFeePerGas (number, optional): EIP-1559 max priority fee per gas in wei

Returns: Promise<{hash: string, fee: number}> - Transaction result

Throws: Error if no provider is configured

Example:

quoteSendTransaction(tx)

Estimates the fee for an EVM transaction without sending it.

Parameters:

  • tx (EvmTransaction): The transaction object (same format as sendTransaction)

Returns: Promise<{fee: number}> - Fee estimate in wei

Throws: Error if no provider is configured

Example:

transfer(options)

Transfers ERC20 tokens to another address using the standard transfer function.

Parameters:

  • options (TransferOptions): Transfer options

    • token (string): Token contract address

    • recipient (string): Recipient address

    • amount (number | bigint): Amount in token base units

Returns: Promise<{hash: string, fee: number}> - Transfer result

Throws:

  • Error if no provider is configured

  • Error if fee exceeds transferMaxFee (if configured)

Example:

quoteTransfer(options)

Estimates the fee for an ERC20 token transfer.

Parameters:

  • options (TransferOptions): Transfer options (same as transfer)

Returns: Promise<{fee: number}> - Fee estimate in wei

Throws: Error if no provider is configured

Example:

getBalance()

Returns the native token balance (ETH, MATIC, BNB, etc.).

Returns: Promise<number> - Balance in wei

Throws: Error if no provider is configured

Example:

getTokenBalance(tokenAddress)

Returns the balance of a specific ERC20 token using the balanceOf function.

Parameters:

  • tokenAddress (string): The ERC20 token contract address

Returns: Promise<number> - Token balance in base units

Throws: Error if no provider is configured

Example:

toReadOnlyAccount()

Creates a read-only copy of the account with the same configuration.

Returns: Promise<WalletAccountReadOnlyEvm> - Read-only account instance

Example:

dispose()

Disposes the wallet account, erasing the private key from memory.

Example:

Properties

Property
Type
Description

index

number

The derivation path's index of this account

path

string

The full BIP-44 derivation path of this account

keyPair

{privateKey: Buffer, publicKey: Buffer}

The account's key pair (⚠️ Contains sensitive data)

Example:

⚠️ Security Note: The keyPair property contains sensitive cryptographic material. Never log, display, or expose the private key.

WalletAccountReadOnlyEvm

Represents a read-only wallet account that can query balances and estimate fees but cannot send transactions.

Constructor

Parameters:

  • address (string): The account's Ethereum address

  • config (object, optional): Configuration object

    • provider (string | Eip1193Provider, optional): RPC endpoint URL or EIP-1193 provider instance

Example:

Methods

Method
Description
Returns
Throws

getBalance()

Returns the native token balance (in wei)

Promise<number>

If no provider

getTokenBalance(tokenAddress)

Returns the balance of a specific ERC20 token

Promise<number>

If no provider

quoteSendTransaction(tx)

Estimates the fee for an EVM transaction

Promise<{fee: number}>

If no provider

quoteTransfer(options)

Estimates the fee for an ERC20 transfer

Promise<{fee: number}>

If no provider

getTransactionReceipt(hash)

Returns a transaction's receipt

Promise<EvmTransactionReceipt | null>

If no provider

getBalance()

Returns the account's native token balance.

Returns: Promise<number> - Balance in wei

Throws: Error if no provider is configured

Example:

getTokenBalance(tokenAddress)

Returns the balance of a specific ERC20 token.

Parameters:

  • tokenAddress (string): The ERC20 token contract address

Returns: Promise<number> - Token balance in base units

Throws: Error if no provider is configured

Example:

quoteSendTransaction(tx)

Estimates the fee for an EVM transaction.

Parameters:

  • tx (EvmTransaction): The transaction object

Returns: Promise<{fee: number}> - Fee estimate in wei

Throws: Error if no provider is configured

Example:

quoteTransfer(options)

Estimates the fee for an ERC20 token transfer.

Parameters:

  • options (TransferOptions): Transfer options

Returns: Promise<{fee: number}> - Fee estimate in wei

Throws: Error if no provider is configured

Example:

getTransactionReceipt(hash)

Returns a transaction's receipt if it has been mined.

Parameters:

  • hash (string): The transaction hash

Returns: Promise<EvmTransactionReceipt | null> - Transaction receipt or null if not yet mined

Throws: Error if no provider is configured

Example:

This comprehensive API Reference now includes all methods from the source code with detailed descriptions, parameters, return types, error conditions, and practical examples.

Types

EvmTransaction

TransferOptions

TransactionResult

TransferResult

FeeRates

KeyPair

EvmWalletConfig

EvmTransactionReceipt


Need Help?