API Reference
Complete API documentation for @tetherto/wdk-wallet-evm-erc-4337
Table of Contents
Main class for managing ERC-4337 EVM wallets. Extends WalletManager from @tetherto/wdk-wallet.
Individual ERC-4337 wallet account implementation. Extends WalletAccountReadOnlyEvmErc4337 and implements IWalletAccount.
Read-only ERC-4337 wallet account. Extends WalletAccountReadOnly from @tetherto/wdk-wallet.
Error thrown when the wallet configuration is invalid or has missing required fields.
-
WalletManagerEvmErc4337
The main class for managing ERC-4337 EVM wallets. Extends WalletManager from @tetherto/wdk-wallet.
Constructor
new WalletManagerEvmErc4337(seed, config)Parameters:
seed(string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytesconfig(EvmErc4337WalletConfig): Configuration object with common fields and a gas payment mode
Common config fields (required for all modes):
chainId(number): The blockchain's ID (e.g., 1 for Ethereum mainnet)provider(string | Eip1193Provider): RPC endpoint URL or EIP-1193 provider instancebundlerUrl(string): The URL of the bundler serviceentryPointAddress(string): The address of the entry point smart contractsafeModulesVersion(string): The Safe modules version (e.g.,'0.3.0')
Gas payment mode (one of the following):
Fees are paid using an ERC-20 token through a paymaster service.
paymasterUrl(string): The URL of the paymaster servicepaymasterAddress(string): The address of the paymaster smart contractpaymasterToken(object): The paymaster token configurationaddress(string): The address of the ERC-20 token used for fees
transferMaxFee(number | bigint, optional): Maximum fee limit in paymaster token units
Fees are sponsored by a third party via a sponsorship policy.
isSponsored(true): Enables sponsorship modepaymasterUrl(string): The URL of the paymaster servicesponsorshipPolicyId(string, optional): The sponsorship policy ID
Fees are paid using the chain's native token (e.g., ETH).
useNativeCoins(true): Enables native coin fee paymenttransferMaxFee(number | bigint, optional): Maximum fee limit in native token units
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<WalletAccountEvmErc4337>
-
getAccountByPath(path)
Returns a wallet account at the specified BIP-44 derivation path
Promise<WalletAccountEvmErc4337>
-
getFeeRates()
Returns current fee rates for transactions
Promise<{normal: bigint, fast: bigint}>
If no provider
dispose()
Disposes all wallet accounts, clearing private keys from memory
void
-
Properties
seed
Uint8Array
The wallet's seed phrase as 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 using BIP-44 derivation.
Parameters:
index(number, optional): The index of the account to get (default: 0)
Returns: Promise<WalletAccountEvmErc4337> - 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<WalletAccountEvmErc4337> - The wallet account
Example:
getFeeRates()
getFeeRates()Returns current fee rates with ERC-4337 specific multipliers.
Returns: Promise<{normal: bigint, fast: bigint}> - Fee rates in wei
Throws: Error if no provider is configured
Example:
dispose()
dispose()Disposes all wallet accounts, clearing private keys from memory.
Example:
WalletAccountEvmErc4337
Represents an individual ERC-4337 wallet account. Extends WalletAccountReadOnlyEvmErc4337 and implements IWalletAccount.
Constructor
Parameters:
seed(string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytespath(string): BIP-44 derivation path (e.g., "0'/0/0")config(EvmErc4337WalletConfig): Configuration object (same as WalletManagerEvmErc4337)
Example:
Methods
predictSafeAddress(owner, config)
(static) Predicts the Safe address for a given owner
string
-
getAddress()
Returns the Safe 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, config?)
Sends a transaction via UserOperation
Promise<{hash: string, fee: bigint}>
If fee exceeds max
quoteSendTransaction(tx, config?)
Estimates the fee for a UserOperation
Promise<{fee: bigint}>
-
transfer(options, config?)
Transfers ERC20 tokens via UserOperation
Promise<{hash: string, fee: bigint}>
If fee exceeds max
quoteTransfer(options, config?)
Estimates the fee for an ERC20 transfer
Promise<{fee: bigint}>
-
approve(options)
Approves a spender to spend ERC20 tokens
Promise<{hash: string, fee: bigint}>
-
getBalance()
Returns the native token balance (in wei)
Promise<bigint>
-
getTokenBalance(tokenAddress)
Returns the balance of a specific ERC20 token
Promise<bigint>
-
getTokenBalances(tokenAddresses)
Returns balances for multiple ERC20 tokens
Promise<Record<string, bigint>>
-
getPaymasterTokenBalance()
Returns the paymaster token balance
Promise<bigint>
-
getAllowance(token, spender)
Returns current token allowance for a spender
Promise<bigint>
-
getTransactionReceipt(hash)
Returns a transaction receipt
Promise<EvmTransactionReceipt | null>
-
getUserOperationReceipt(hash)
Returns a UserOperation receipt
Promise<UserOperationReceipt | null>
-
toReadOnlyAccount()
Returns a read-only copy of the account
Promise<WalletAccountReadOnlyEvmErc4337>
-
dispose()
Disposes the wallet account, clearing private keys from memory
void
-
getAddress()
Returns the Safe smart contract wallet address (not the underlying EOA address).
Returns: Promise<string> - The Safe account's address
Example:
sign(message)
Signs a message using the underlying EOA private key.
Parameters:
message(string): The message to sign
Returns: Promise<string> - The message signature
Example:
signTypedData(typedData)
Signs typed data according to EIP-712.
Parameters:
typedData(TypedData): The typed data to sign
Returns: Promise<string> - The typed data signature
Example:
verify(message, signature)
Verifies a message signature against the underlying EOA address.
Parameters:
message(string): The original messagesignature(string): The signature to verify
Returns: Promise<boolean> - True if signature is valid
Example:
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, config?)
Sends a transaction via UserOperation through the bundler.
Parameters:
tx(EvmTransaction | EvmTransaction[]): Transaction object or array for batch transactionsto(string): Recipient addressvalue(number | bigint): Amount in weidata(string, optional): Transaction data in hex format
config(optional): Per-call configuration override. Accepts a partial version of the gas payment mode fields (see Config Override).
Returns: Promise<{hash: string, fee: bigint}> - UserOperation hash and fee
Throws: Error if fee exceeds transferMaxFee
Example:
quoteSendTransaction(tx, config?)
Estimates the fee for a UserOperation without sending it.
Parameters:
tx(EvmTransaction | EvmTransaction[]): Transaction object or array (same as sendTransaction)config(optional): Per-call configuration override (see Config Override)
Returns: Promise<{fee: bigint}> - Fee estimate
Example:
transfer(options, config?)
Transfers ERC20 tokens via UserOperation.
Parameters:
options(TransferOptions): Transfer optionstoken(string): ERC20 token contract addressrecipient(string): Recipient addressamount(number | bigint): Amount in token base units
config(optional): Per-call configuration override (see Config Override)
Returns: Promise<{hash: string, fee: bigint}> - UserOperation hash and fee
Throws:
Error if fee exceeds
transferMaxFeeError if insufficient token balance
Example:
quoteTransfer(options, config?)
Estimates the fee for an ERC20 token transfer.
Parameters:
options(TransferOptions): Transfer options (same as transfer)config(optional): Per-call configuration override (see Config Override)
Returns: Promise<{fee: bigint}> - Fee estimate
Example:
getBalance()
Returns the Safe account's native token balance.
Returns: Promise<bigint> - Balance in wei
Example:
getTokenBalance(tokenAddress)
Returns the balance of a specific ERC20 token in the Safe account.
Parameters:
tokenAddress(string): The ERC20 token contract address
Returns: Promise<bigint> - Token balance in base units
Example:
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
Example:
getPaymasterTokenBalance()
Returns the balance of the configured paymaster token used for paying fees.
Returns: Promise<bigint> - Paymaster token balance in base units
Example:
approve(options)
Approves a spender to spend ERC20 tokens on behalf of the Safe account.
Parameters:
options(ApproveOptions): Approve optionstoken(string): ERC20 token contract addressspender(string): The address allowed to spend the tokensamount(number | bigint): Amount to approve in token base units
Returns: Promise<{hash: string, fee: bigint}> - Transaction result
Example:
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
Example:
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
Example:
getUserOperationReceipt(hash)
Returns a UserOperation receipt by hash.
Parameters:
hash(string): The UserOperation hash
Returns: Promise<UserOperationReceipt | null> - UserOperation receipt or null if not processed
Example:
toReadOnlyAccount()
Creates a read-only copy of the account with the same Safe address and configuration.
Returns: Promise<WalletAccountReadOnlyEvmErc4337> - Read-only account instance
Example:
dispose()
Disposes the wallet account, clearing private keys 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)
Example:
⚠️ Security Note: The keyPair property contains sensitive cryptographic material. Never log, display, or expose the private key.
WalletAccountReadOnlyEvmErc4337
Represents a read-only ERC-4337 wallet account that can query balances and estimate fees but cannot send transactions.
Constructor
Parameters:
address(string): The EOA address (owner address)config(Omit<EvmErc4337WalletConfig, 'transferMaxFee'>): Configuration object withouttransferMaxFee
Example:
Static Methods
predictSafeAddress(owner, config)
Predicts the Safe address for a given owner without instantiating an account
string
predictSafeAddress(owner, config) (static)
predictSafeAddress(owner, config) (static)Predicts the address of a Safe account.
Parameters:
owner(string): The Safe owner's EOA addressconfig(object): Configuration with:chainId(number): The blockchain IDsafeModulesVersion(string): The Safe modules version
Returns: string - The predicted Safe address
Example:
Methods
getAddress()
Returns the Safe account's address
Promise<string>
-
verify(message, signature)
Verifies a message signature
Promise<boolean>
-
verifyTypedData(typedData, signature)
Verifies a typed data signature (EIP-712)
Promise<boolean>
-
getBalance()
Returns the native token balance (in wei)
Promise<bigint>
-
getTokenBalance(tokenAddress)
Returns the balance of a specific ERC20 token
Promise<bigint>
-
getTokenBalances(tokenAddresses)
Returns balances for multiple ERC20 tokens
Promise<Record<string, bigint>>
-
getPaymasterTokenBalance()
Returns the paymaster token balance
Promise<bigint>
-
getAllowance(token, spender)
Returns current token allowance for a spender
Promise<bigint>
-
quoteSendTransaction(tx, config?)
Estimates the fee for a UserOperation
Promise<{fee: bigint}>
If simulation fails
quoteTransfer(options, config?)
Estimates the fee for an ERC20 transfer
Promise<{fee: bigint}>
If simulation fails
getTransactionReceipt(hash)
Returns a transaction receipt
Promise<EvmTransactionReceipt | null>
-
getUserOperationReceipt(hash)
Returns a UserOperation receipt
Promise<UserOperationReceipt | null>
-
getAddress()
Returns the Safe smart contract wallet address.
Returns: Promise<string> - The Safe account's address
Example:
verify(message, signature)
Verifies a message signature against the underlying EOA address.
Parameters:
message(string): The original messagesignature(string): The signature to verify
Returns: Promise<boolean> - True if signature is valid
Example:
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:
getBalance()
Returns the Safe account's native token balance.
Returns: Promise<bigint> - Balance in wei
Example:
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
Example:
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
Example:
getPaymasterTokenBalance()
Returns the balance of the configured paymaster token.
Returns: Promise<bigint> - Paymaster token balance in base units
Example:
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
Example:
quoteSendTransaction(tx, config?)
Estimates the fee for a UserOperation.
Parameters:
tx(EvmTransaction | EvmTransaction[]): Transaction object or arrayconfig(optional): Per-call configuration override (see Config Override)
Returns: Promise<{fee: bigint}> - Fee estimate
Throws: Error if simulation fails
Example:
quoteTransfer(options, config?)
Estimates the fee for an ERC20 token transfer.
Parameters:
options(TransferOptions): Transfer optionsconfig(optional): Per-call configuration override (see Config Override)
Returns: Promise<{fee: bigint}> - Fee estimate
Example:
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
Example:
getUserOperationReceipt(hash)
Returns a UserOperation receipt by hash.
Parameters:
hash(string): The UserOperation hash
Returns: Promise<UserOperationReceipt | null> - UserOperation receipt or null if not processed
Example:
Types
The following types are exported from @tetherto/wdk-wallet-evm-erc-4337 and can be imported directly.
Exported configuration subtypes:
EvmErc4337WalletCommonConfigEvmErc4337WalletPaymasterTokenConfigEvmErc4337WalletSponsorshipPolicyConfigEvmErc4337WalletNativeCoinsConfig
TypedData
TypedDataDomain
TypedDataField
EvmErc4337WalletConfig
The configuration is a union type combining common fields with one of three gas payment modes:
Config Override
The config parameter on sendTransaction, quoteSendTransaction, transfer, and quoteTransfer allows per-call overrides of gas payment settings:
Available override fields:
isSponsored(boolean): Switch to sponsorship modeuseNativeCoins(boolean): Switch to native coin modepaymasterUrl(string): Override paymaster URLpaymasterAddress(string): Override paymaster contractpaymasterToken({address: string}): Override paymaster tokensponsorshipPolicyId(string): Set sponsorship policytransferMaxFee(number | bigint): Override maximum fee
EvmTransaction
TransferOptions
ApproveOptions
TransactionResult
TransferResult
UserOperationReceipt
ConfigurationError
FeeRates
KeyPair
Internal Constants
The following constants are used internally by the SDK and are not importable from the package entry point.

