githubEdit

book-openUsage

Installation, quick start, and usage examples for @tetherto/wdk-wallet-evm

Installation

To install the @tetherto/wdk-wallet-evm package, follow these instructions:

npm install @tetherto/wdk-wallet-evm

Quick Start

Creating a New Wallet

triangle-exclamation
import WalletManagerEvm, { WalletAccountEvm, WalletAccountReadOnlyEvm } from '@tetherto/wdk-wallet-evm'


// Generate a new random seed phrase (you'll need to implement this or use a library)
const seedPhrase = 'your twelve word seed phrase here' // Replace with actual seed generation
console.log('Seed phrase:', seedPhrase)

// Create wallet manager with RPC provider
const wallet = new WalletManagerEvm(seedPhrase, {
  provider: 'https://rpc.mevblocker.io/fast', // or any other RPC provider
  transferMaxFee: 100000000000000 // Optional: Maximum fee in wei
})

// Option 2: Using EIP-1193 provider (e.g., from browser wallet)
const wallet2 = new WalletManagerEvm(seedPhrase, {
  provider: window.ethereum, // EIP-1193 provider
  transferMaxFee: 100000000000000 // Optional: Maximum fee in wei
})

// Get a full access account
const account = await wallet.getAccount(0)

// Convert to a read-only account
const readOnlyAccount = await account.toReadOnlyAccount()
circle-info

RPC Providers: The examples use public RPC endpoints for demonstration. We do not endorse any specific provider.

  • Testnets: You can find public RPCs for Ethereum and other EVM chains on Chainlistarrow-up-right.

  • Mainnet: For production environments, we recommend using reliable, paid RPC providers to ensure stability.

circle-info

To use test/mock tokens instead of real funds, see the Testnet configuration section.

Managing Multiple Accounts

Checking Balances

Owned Account

Read-Only Account

Sending Transactions

circle-info

Gas Estimation: The maxFeePerGas and maxPriorityFeePerGas fields enable EIP-1559 transactions, ensuring more predictable gas fees and faster inclusion times.

Token Transfers

Message Signing and Verification

Fee Management

Memory Management

Complete Examples

Complete Wallet Setup

Multi-Account Management

Advanced Transaction Example

Token Transfer with Validation

Error Handling


Need Help?