API Reference
Complete API documentation for @tetherto/wdk-wallet-evm
Table of Contents
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.
Constructor
new WalletManagerEvm(seed, config?)Parameters:
seed(string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytesconfig(object, optional): Configuration objectprovider(string | Eip1193Provider, optional): RPC endpoint URL or EIP-1193 provider instancetransferMaxFee(number | bigint, optional): Maximum fee amount for transfer operations (in wei)
Example:
const wallet = new WalletManagerEvm(seedPhrase, {
provider: 'https://rpc.mevblocker.io/fast',
transferMaxFee: 100000000000000 // Maximum fee in wei
})Methods
getRandomSeedPhrase(wordCount?)
(static) Returns a random BIP-39 seed phrase
string
-
isValidSeedPhrase(seedPhrase)
(static) Checks if a seed phrase is valid
boolean
-
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: bigint, fast: bigint}>
If no provider is set
dispose()
Disposes all wallet accounts, clearing private keys from memory
void
-
Properties
seed
Uint8Array
The wallet's seed bytes
getRandomSeedPhrase(wordCount?) (static)
getRandomSeedPhrase(wordCount?) (static)Returns a random BIP-39 seed phrase.
Parameters:
wordCount(12 | 24, optional): The number of words in the seed phrase (default: 12)
Returns: string - The seed phrase
Example:
isValidSeedPhrase(seedPhrase) (static)
isValidSeedPhrase(seedPhrase) (static)Checks if a seed phrase is valid.
Parameters:
seedPhrase(string): The seed phrase to validate
Returns: boolean - True if the seed phrase is valid
Example:
getAccount(index?)
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)
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()
getFeeRates()Returns current fee rates based on network conditions with predefined multipliers.
Returns: Promise<{normal: bigint, fast: bigint}> - 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()
dispose()Disposes all wallet accounts, clearing private keys from memory.
Example:
WalletAccountEvm
Represents an individual wallet account. Extends WalletAccountReadOnlyEvm and implements IWalletAccount from @tetherto/wdk-wallet.
Constructor
Parameters:
seed(string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytespath(string): BIP-44 derivation path (e.g., "0'/0/0")config(object, optional): Configuration objectprovider(string | Eip1193Provider, optional): RPC endpoint URL or EIP-1193 provider instancetransferMaxFee(number | bigint, optional): Maximum fee amount for transfer operations (in wei)
Throws:
Error if seed phrase is invalid (BIP-39 validation fails)
Example:
Methods
getAddress()
Returns the account's address
Promise<string>
-
sign(message)
Signs a message using the account's private key
Promise<string>
-
signTypedData(typedData)
Signs typed data according to EIP-712
Promise<string>
-
verify(message, signature)
Verifies a message signature
Promise<boolean>
-
verifyTypedData(typedData, signature)
Verifies a typed data signature (EIP-712)
Promise<boolean>
-
sendTransaction(tx)
Sends an EVM transaction
Promise<{hash: string, fee: bigint}>
If no provider
quoteSendTransaction(tx)
Estimates the fee for an EVM transaction
Promise<{fee: bigint}>
If no provider
transfer(options)
Transfers ERC20 tokens to another address
Promise<{hash: string, fee: bigint}>
If no provider or fee exceeds max
quoteTransfer(options)
Estimates the fee for an ERC20 transfer
Promise<{fee: bigint}>
If no provider
getBalance()
Returns the native token balance (in wei)
Promise<bigint>
If no provider
getTokenBalance(tokenAddress)
Returns the balance of a specific ERC20 token
Promise<bigint>
If no provider
getTokenBalances(tokenAddresses)
Returns balances for multiple ERC20 tokens
Promise<Record<string, bigint>>
If no provider
approve(options)
Approves a spender to spend tokens
Promise<{hash: string, fee: bigint}>
If no provider
getAllowance(token, spender)
Returns current allowance for a spender
Promise<bigint>
If no provider
getTransactionReceipt(hash)
Returns a transaction's receipt
Promise<EvmTransactionReceipt | null>
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()
getAddress()Returns the account's Ethereum address.
Returns: Promise<string> - Checksummed Ethereum address
Example:
sign(message)
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:
signTypedData(typedData)
signTypedData(typedData)Signs typed data according to EIP-712.
Parameters:
typedData(TypedData): The typed data to signdomain(TypedDataDomain): The domain separator (name, version, chainId, verifyingContract)types(Record<string, TypedDataField[]>): The type definitionsmessage(Record<string, unknown>): The message data
Returns: Promise<string> - The typed data signature
Example:
verify(message, signature)
verify(message, signature)Verifies a message signature against the account's address.
Parameters:
message(string): The original messagesignature(string): The signature to verify
Returns: Promise<boolean> - True if signature is valid
Example:
verifyTypedData(typedData, signature)
verifyTypedData(typedData, signature)Verifies a typed data signature according to EIP-712.
Parameters:
typedData(TypedData): The typed data that was signedsignature(string): The signature to verify
Returns: Promise<boolean> - True if signature is valid
Example:
sendTransaction(tx)
sendTransaction(tx)Sends an EVM transaction and returns the result with hash and fee.
Parameters:
tx(EvmTransaction): The transaction objectto(string): Recipient addressvalue(number | bigint): Amount in weidata(string, optional): Transaction data in hex formatgasLimit(number | bigint, optional): Maximum gas unitsgasPrice(number | bigint, optional): Legacy gas price in weimaxFeePerGas(number | bigint, optional): EIP-1559 max fee per gas in weimaxPriorityFeePerGas(number | bigint, optional): EIP-1559 max priority fee per gas in wei
Returns: Promise<{hash: string, fee: bigint}> - Transaction result
Throws: Error if no provider is configured
Example:
quoteSendTransaction(tx)
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: bigint}> - Fee estimate in wei
Throws: Error if no provider is configured
Example:
transfer(options)
transfer(options)Transfers ERC20 tokens to another address using the standard transfer function.
Parameters:
options(TransferOptions): Transfer optionstoken(string): Token contract addressrecipient(string): Recipient addressamount(number | bigint): Amount in token base units
Returns: Promise<{hash: string, fee: bigint}> - Transfer result
Throws:
Error if no provider is configured
Error if fee exceeds
transferMaxFee(if configured)
Example:
quoteTransfer(options)
quoteTransfer(options)Estimates the fee for an ERC20 token transfer.
Parameters:
options(TransferOptions): Transfer options (same as transfer)
Returns: Promise<{fee: bigint}> - Fee estimate in wei
Throws: Error if no provider is configured
Example:
getBalance()
getBalance()Returns the native token balance (ETH, MATIC, BNB, etc.).
Returns: Promise<bigint> - Balance in wei
Throws: Error if no provider is configured
Example:
getTokenBalance(tokenAddress)
getTokenBalance(tokenAddress)Returns the balance of a specific ERC20 token using the balanceOf function.
Parameters:
tokenAddress(string): The ERC20 token contract address
Returns: Promise<bigint> - Token balance in base units
Throws: Error if no provider is configured
Example:
getTokenBalances(tokenAddresses)
getTokenBalances(tokenAddresses)Returns balances for multiple ERC20 tokens in one call.
Parameters:
tokenAddresses(string[]): List of ERC20 token contract addresses
Returns: Promise<Record<string, bigint>> - Object mapping each token address to its balance in base units
Throws: Error if no provider is configured
Example:
approve(options)
approve(options)Approves a specific amount of tokens to a spender.
Parameters:
options(ApproveOptions): Approve optionstoken(string): Token contract addressspender(string): Spender addressamount(number | bigint): Amount to approve
Returns: Promise<{hash: string, fee: bigint}> - Transaction result
Throws:
Error if no provider is configured
Error if trying to re-approve USDT on Ethereum without resetting to 0 first
Example:
getAllowance(token, spender)
getAllowance(token, spender)Returns the current token allowance for the given spender.
Parameters:
token(string): ERC20 token contract addressspender(string): The spender's address
Returns: Promise<bigint> - The current allowance
Throws: Error if no provider is configured
Example:
getTransactionReceipt(hash)
getTransactionReceipt(hash)Returns a transaction receipt by hash.
Parameters:
hash(string): The transaction hash
Returns: Promise<EvmTransactionReceipt | null> - Transaction receipt or null if not mined
Throws: Error if no provider is configured
Example:
toReadOnlyAccount()
toReadOnlyAccount()Creates a read-only copy of the account with the same configuration.
Returns: Promise<WalletAccountReadOnlyEvm> - Read-only account instance
Example:
dispose()
dispose()Disposes the wallet account, erasing the private key from memory.
Example:
Properties
index
number
The derivation path's index of this account
path
string
The full BIP-44 derivation path of this account
keyPair
{privateKey: Uint8Array | null, publicKey: Uint8Array}
The account's key pair (⚠️ Contains sensitive data)
address
string
The account's Ethereum address (inherited from WalletAccountReadOnlyEvm)
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 addressconfig(Omit<EvmWalletConfig, 'transferMaxFee'>, optional): Configuration object (same asEvmWalletConfigbut withouttransferMaxFee, since read-only accounts cannot send transactions)provider(string | Eip1193Provider, optional): RPC endpoint URL or EIP-1193 provider instance
Example:
Properties
address
string
The account's Ethereum address
Methods
getAddress()
Returns the account's address
Promise<string>
-
getBalance()
Returns the native token balance (in wei)
Promise<bigint>
If no provider
getTokenBalance(tokenAddress)
Returns the balance of a specific ERC20 token
Promise<bigint>
If no provider
getTokenBalances(tokenAddresses)
Returns balances for multiple ERC20 tokens
Promise<Record<string, bigint>>
If no provider
quoteSendTransaction(tx)
Estimates the fee for an EVM transaction
Promise<{fee: bigint}>
If no provider
quoteTransfer(options)
Estimates the fee for an ERC20 transfer
Promise<{fee: bigint}>
If no provider
verify(message, signature)
Verifies a message signature
Promise<boolean>
-
verifyTypedData(typedData, signature)
Verifies a typed data signature (EIP-712)
Promise<boolean>
-
getTransactionReceipt(hash)
Returns a transaction's receipt
Promise<EvmTransactionReceipt | null>
If no provider
getAllowance(token, spender)
Returns current allowance for a spender
Promise<bigint>
If no provider
getAddress()
getAddress()Returns the account's Ethereum address.
Returns: Promise<string> - Checksummed Ethereum address
Example:
getBalance()
getBalance()Returns the account's native token balance.
Returns: Promise<bigint> - Balance in wei
Throws: Error if no provider is configured
Example:
getTokenBalance(tokenAddress)
getTokenBalance(tokenAddress)Returns the balance of a specific ERC20 token.
Parameters:
tokenAddress(string): The ERC20 token contract address
Returns: Promise<bigint> - Token balance in base units
Throws: Error if no provider is configured
Example:
getTokenBalances(tokenAddresses)
getTokenBalances(tokenAddresses)Returns balances for multiple ERC20 tokens.
Parameters:
tokenAddresses(string[]): List of ERC20 token contract addresses
Returns: Promise<Record<string, bigint>> - Object mapping each token address to its balance in base units
Throws: Error if no provider is configured
Example:
quoteSendTransaction(tx)
quoteSendTransaction(tx)Estimates the fee for an EVM transaction.
Parameters:
tx(EvmTransaction): The transaction object
Returns: Promise<{fee: bigint}> - Fee estimate in wei
Throws: Error if no provider is configured
Example:
quoteTransfer(options)
quoteTransfer(options)Estimates the fee for an ERC20 token transfer.
Parameters:
options(TransferOptions): Transfer options
Returns: Promise<{fee: bigint}> - Fee estimate in wei
Throws: Error if no provider is configured
Example:
verify(message, signature)
verify(message, signature)Verifies a message signature against the account's address.
Parameters:
message(string): The original messagesignature(string): The signature to verify
Returns: Promise<boolean> - True if signature is valid
Example:
verifyTypedData(typedData, signature)
verifyTypedData(typedData, signature)Verifies a typed data signature according to EIP-712.
Parameters:
typedData(TypedData): The typed data that was signedsignature(string): The signature to verify
Returns: Promise<boolean> - True if signature is valid
Example:
getTransactionReceipt(hash)
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:
getAllowance(token, spender)
getAllowance(token, spender)Returns the current allowance for the given token and spender.
Parameters:
token(string): The token's addressspender(string): The spender's address
Returns: Promise<bigint> - The allowance
Example:

