WDK logoWDK documentation

Wallet EVM 7702 Gasless API Reference

Complete API documentation for @tetherto/wdk-wallet-evm-7702-gasless.

Table of Contents

ExportDescription
WalletManagerEvm7702GaslessDefault export. Manages EIP-7702 gasless EVM wallet accounts.
WalletAccountEvm7702GaslessOwned EIP-7702 gasless account with signing, approval, transfer, and send methods.
WalletAccountReadOnlyEvm7702GaslessRead-only account with balances, quotes, receipts, allowances, and verification.
ConfigurationErrorError thrown for invalid wallet configuration.
Config TypesEvm7702GaslessWalletConfig and related fee-mode types.

WalletManagerEvm7702Gasless

Default export from @tetherto/wdk-wallet-evm-7702-gasless.

import WalletManagerEvm7702Gasless from '@tetherto/wdk-wallet-evm-7702-gasless'

Constructor

new WalletManagerEvm7702Gasless(seed, config)
ParameterTypeDescription
seedstring | Uint8ArrayBIP-39 mnemonic seed phrase or seed bytes.
configEvm7702GaslessWalletConfigWallet configuration with common fields and one fee mode.

Methods

MethodParametersReturnsNotes
getAccount(index?)index?: numberPromise\<WalletAccountEvm7702Gasless\>Defaults to index 0 and derives 0'/0/{index}.
getAccountByPath(path)path: stringPromise\<WalletAccountEvm7702Gasless\>Returns a cached account for the derivation path suffix.
getFeeRates()-Promise\<{ normal: bigint, fast: bigint }\>Uses provider fee data. Throws if no provider is connected.
dispose()-voidInherited from WalletManager; disposes managed accounts.

getFeeRates() returns fee rates in wei. The normal value applies the EVM wallet normal multiplier, and fast applies the EVM wallet fast multiplier to the provider fee.

WalletAccountEvm7702Gasless

Named export for owned EIP-7702 gasless accounts.

import { WalletAccountEvm7702Gasless } from '@tetherto/wdk-wallet-evm-7702-gasless'

Constructors

new WalletAccountEvm7702Gasless(seed, path, config)
new WalletAccountEvm7702Gasless(walletAccountEvm, config)
ParameterTypeDescription
seedstring | Uint8ArrayBIP-39 mnemonic seed phrase or seed bytes.
pathstringEVM derivation path suffix, for example "0'/0/0".
walletAccountEvmWalletAccountEvmExisting EVM account to wrap.
configEvm7702GaslessWalletConfigWallet configuration.

Properties

PropertyTypeDescription
indexnumberDerivation path index from the wrapped EVM account.
pathstringFull derivation path from the wrapped EVM account.
keyPairKeyPairRead-only view of the wrapped EVM account key pair.

Treat the arrays returned through keyPair as read-only. Call dispose() when the account is no longer needed.

Methods

MethodParametersReturnsNotes
getAddress()-Promise\<string\>Inherited read-only method. Returns the EOA address.
getBalance()-Promise\<bigint\>Native token balance in wei.
getTokenBalance(tokenAddress)tokenAddress: stringPromise\<bigint\>ERC-20 balance in base units.
getTokenBalances(tokenAddresses)tokenAddresses: string[]Promise\<Record\<string, bigint\>\>Multiple ERC-20 balances in base units.
getPaymasterTokenBalance()-Promise\<bigint\>Throws ConfigurationError when no paymasterToken is configured.
sign(message)message: stringPromise\<string\>Signs with the wrapped EVM account.
signTypedData(typedData)TypedDataPromise\<string\>Signs EIP-712 typed data.
verify(message, signature)message: string, signature: stringPromise\<boolean\>Verifies a plain message signature.
verifyTypedData(typedData, signature)TypedData, signature: stringPromise\<boolean\>Verifies EIP-712 typed data.
approve(options)ApproveOptionsPromise\<TransactionResult\>Sends an ERC-20 approval as a UserOperation.
quoteSendTransaction(tx, config?)EvmTransaction | EvmTransaction[], partial fee-mode configPromise\<Omit\<TransactionResult, 'hash'\>\>Returns { fee }; owned accounts cache paymaster-token quotes for up to 2 minutes.
sendTransaction(tx, config?)EvmTransaction | EvmTransaction[], partial fee-mode configPromise\<TransactionResult\>Returns a UserOperation hash and fee.
quoteTransfer(options, config?)EvmTransferOptions, partial fee-mode configPromise\<Omit\<TransferResult, 'hash'\>\>Quotes an ERC-20 transfer.
transfer(options, config?)EvmTransferOptions, partial fee-mode configPromise\<TransferResult\>Sends an ERC-20 transfer as a UserOperation.
getAllowance(token, spender)token: string, spender: stringPromise\<bigint\>Reads ERC-20 allowance.
getUserOperationReceipt(hash)hash: stringPromise\<UserOperationReceipt | null\>Reads the raw bundler receipt.
getTransactionReceipt(hash)hash: stringPromise\<EvmTransactionReceipt | null\>Maps a UserOperation hash to an EVM receipt when included.
toReadOnlyAccount()-Promise\<WalletAccountReadOnlyEvm7702Gasless\>Returns a cached read-only account.
dispose()-voidClears quote cache and disposes the wrapped EVM account.

Quote and Send Behavior

  • Sponsored mode returns fee: 0n from quote methods.
  • Paymaster-token mode returns fees in the configured paymaster token's base units.
  • Owned account quotes are cached for up to 2 minutes for the same serialized transaction.
  • sendTransaction() signs the UserOperation typed data before submitting it to the bundler.
  • If the account is already delegated to delegationAddress, the send path does not include a new EIP-7702 authorization.

Transfer Fee Cap

transfer() checks transferMaxFee only in paymaster-token mode. It throws when the estimated fee is greater than or equal to the configured cap.

USDT Approval Rule

On Ethereum mainnet, approve() checks the USDT allowance rule. If the current allowance is non-zero and the requested amount is non-zero, the method throws before sending. Send an approval with amount 0 first, then send the new non-zero approval.

WalletAccountReadOnlyEvm7702Gasless

Named export for read-only accounts.

import { WalletAccountReadOnlyEvm7702Gasless } from '@tetherto/wdk-wallet-evm-7702-gasless'

Constructor

new WalletAccountReadOnlyEvm7702Gasless(address, config)
ParameterTypeDescription
addressstringEOA address.
configOmit\<Evm7702GaslessWalletConfig, 'transferMaxFee'\>Read-only configuration.

Methods

MethodParametersReturnsNotes
getAddress()-Promise\<string\>Returns the configured address.
getBalance()-Promise\<bigint\>Native token balance in wei.
getTokenBalance(tokenAddress)tokenAddress: stringPromise\<bigint\>ERC-20 balance in base units.
getTokenBalances(tokenAddresses)tokenAddresses: string[]Promise\<Record\<string, bigint\>\>Multiple ERC-20 balances.
getPaymasterTokenBalance()-Promise\<bigint\>Reads the configured paymaster token balance.
quoteSendTransaction(tx, config?)EvmTransaction | EvmTransaction[], partial fee-mode configPromise\<Omit\<TransactionResult, 'hash'\>\>Quotes without signing or sending.
quoteTransfer(options, config?)EvmTransferOptions, partial fee-mode configPromise\<Omit\<TransferResult, 'hash'\>\>Quotes an ERC-20 transfer.
getAllowance(token, spender)token: string, spender: stringPromise\<bigint\>Reads ERC-20 allowance.
getUserOperationReceipt(hash)hash: stringPromise\<UserOperationReceipt | null\>Reads the raw bundler receipt.
getTransactionReceipt(hash)hash: stringPromise\<EvmTransactionReceipt | null\>Returns null until the UserOperation maps to an EVM transaction.
verify(message, signature)message: string, signature: stringPromise\<boolean\>Verifies a plain message signature.
verifyTypedData(typedData, signature)TypedData, signature: stringPromise\<boolean\>Verifies EIP-712 typed data.

Read-only accounts cannot sign, approve, send, or transfer.

ConfigurationError

import { ConfigurationError } from '@tetherto/wdk-wallet-evm-7702-gasless'

ConfigurationError extends Error and is thrown when wallet configuration is invalid.

Known configuration errors include:

  • missing provider;
  • missing bundlerUrl;
  • missing delegationAddress;
  • missing paymasterToken when isSponsored is absent or false;
  • empty provider array;
  • configured paymasterAddress does not match the paymaster returned by the RPC.

Config Types

Evm7702GaslessWalletCommonConfig

FieldTypeRequiredDescription
providerstring | Eip1193Provider | Array\<string | Eip1193Provider\>YesRPC endpoint, EIP-1193 provider, or provider failover list.
retriesnumberNoAdditional retry attempts for provider arrays. Defaults to 3.
bundlerUrlstringYesERC-4337 bundler endpoint.
paymasterUrlstringNoPaymaster endpoint when different from bundlerUrl.
delegationAddressstringYesSmart-account implementation address used for EIP-7702 delegation.

Evm7702GaslessSponsorshipPolicyConfig

FieldTypeRequiredDescription
isSponsoredtrueYesEnables sponsored fee mode.
sponsorshipPolicyIdstringNoPaymaster sponsorship policy ID.

Evm7702GaslessPaymasterTokenConfig

FieldTypeRequiredDescription
isSponsoredfalseNoOmit or set to false for paymaster-token mode.
paymasterAddressstringNoExpected paymaster contract address.
paymasterToken.addressstringYesERC-20 token used for fee payment.
transferMaxFeenumber | bigintNoMaximum fee for transfer() in token base units.

Evm7702GaslessWalletConfig

type Evm7702GaslessWalletConfig =
  Evm7702GaslessWalletCommonConfig &
  (Evm7702GaslessSponsorshipPolicyConfig | Evm7702GaslessPaymasterTokenConfig)

Exported Types

The package also re-exports EVM wallet types from @tetherto/wdk-wallet-evm, including FeeRates, KeyPair, EvmTransaction, TransactionResult, EvmTransferOptions, TransferResult, EvmTransactionReceipt, ApproveOptions, TypedData, TypedDataDomain, and TypedDataField.

Module-specific exported types include UserOperationReceipt, Eip7702AuthorizationOverride, BuildSponsoredUserOperationOverrides, and SponsoredUserOperation.

On this page