@tetherto/wdk-wallet-evm 1.0.0-beta.2 → 1.0.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md ADDED
@@ -0,0 +1,50 @@
1
+ # Agent Guide
2
+
3
+ This repository is part of the Tether WDK (Wallet Development Kit) ecosystem. It follows strict coding conventions and tooling standards to ensure consistency, reliability, and cross-platform compatibility (Node.js and Bare runtime).
4
+
5
+ ## Project Overview
6
+ - **Architecture:** Modular architecture with clear separation between Core, Wallet managers, and Protocols.
7
+ - **Runtime:** Supports both Node.js and Bare runtime.
8
+
9
+ ## Tech Stack & Tooling
10
+ - **Language:** JavaScript (ES2015+).
11
+ - **Module System:** ES Modules (`"type": "module"` in package.json).
12
+ - **Type Checking:** TypeScript is used purely for generating type declarations (`.d.ts`). The source code remains JavaScript.
13
+ - Command: `npm run build:types`
14
+ - **Linting:** `standard` (JavaScript Standard Style).
15
+ - Command: `npm run lint` / `npm run lint:fix`
16
+ - **Testing:** `jest` (configured with `experimental-vm-modules` for ESM support).
17
+ - Command: `npm test`
18
+ - **Dependencies:** `cross-env` is consistently used for environment variable management in scripts.
19
+
20
+ ## Coding Conventions
21
+ - **File Naming:** Kebab-case (e.g., `wallet-manager.js`).
22
+ - **Class Naming:** PascalCase (e.g., `WdkManager`).
23
+ - **Private Members:** Prefixed with `_` (underscore) and explicitly documented with `@private`.
24
+ - **Imports:** Explicit file extensions are mandatory (e.g., `import ... from './file.js'`).
25
+ - **Copyright:** All source files must include the standard Tether copyright header.
26
+
27
+ ## Documentation (JSDoc)
28
+ Source code must be strictly typed using JSDoc comments to support the `build:types` process.
29
+ - **Types:** Use `@typedef` to define or import types.
30
+ - **Methods:** Use `@param`, `@returns`, `@throws`.
31
+ - **Generics:** Use `@template`.
32
+
33
+ ## Development Workflow
34
+ 1. **Install:** `npm install`
35
+ 2. **Lint:** `npm run lint`
36
+ 3. **Test:** `npm test`
37
+ 4. **Build Types:** `npm run build:types`
38
+
39
+ ## Key Files
40
+ - `index.js`: Main entry point.
41
+ - `bare.js`: Entry point for Bare runtime optimization.
42
+ - `src/`: Core logic.
43
+ - `types/`: Generated type definitions (do not edit manually).
44
+
45
+ ## Repository Specifics
46
+ - **Domain:** EVM Blockchain Wallet Management.
47
+ - **Key Library:** `ethers` (v6).
48
+ - **Standards:** BIP-44 (m/44'/60'), EIP-1559.
49
+ - **Architecture:** Extends base wallet classes to support Ethereum transactions, ERC20 tokens, and fee estimation.
50
+ - **Testing:** Integration tests often use Hardhat.
package/README.md CHANGED
@@ -1,23 +1,19 @@
1
1
  # @tetherto/wdk-wallet-evm
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/%40tetherto%2Fwdk-wallet-evm?style=flat-square)](https://www.npmjs.com/package/@tetherto/wdk-wallet-evm)
4
+ [![npm downloads](https://img.shields.io/npm/dw/%40tetherto%2Fwdk-wallet-evm?style=flat-square)](https://www.npmjs.com/package/@tetherto/wdk-wallet-evm)
5
+ [![license](https://img.shields.io/npm/l/%40tetherto%2Fwdk-wallet-evm?style=flat-square)](https://github.com/tetherto/wdk-wallet-evm/blob/main/LICENSE)
6
+ [![docs](https://img.shields.io/badge/docs-docs.wdk.tether.io-0A66C2?style=flat-square)](https://docs.wdk.tether.io/sdk/wallet-modules/wallet-evm)
3
7
 
4
8
  **Note**: This package is currently in beta. Please test thoroughly in development environments before using in production.
5
9
 
6
- A simple and secure package to manage BIP-44 wallets for EVM-compatible blockchains. This package provides a clean API for creating, managing, and interacting with Ethereum-compatible wallets using BIP-39 seed phrases and EVM-specific derivation paths.
10
+ An EVM wallet module for WDK (Wallet Development Kit) by Tether. This package provides a clean API for creating, managing, and interacting with Ethereum-compatible wallets using BIP-39 seed phrases and EVM-specific derivation paths.
7
11
 
8
- ## 🔍 About WDK
12
+ ## About WDK
9
13
 
10
- This module is part of the [**WDK (Wallet Development Kit)**](https://wallet.tether.io/) project, which empowers developers to build secure, non-custodial wallets with unified blockchain access, stateless architecture, and complete user control.
14
+ This module is part of the [**WDK (Wallet Development Kit)**](https://docs.wdk.tether.io/) project, which empowers developers to build secure, non-custodial wallets with unified blockchain access, stateless architecture, and complete user control.
11
15
 
12
- For detailed documentation about the complete WDK ecosystem, visit [docs.wallet.tether.io](https://docs.wallet.tether.io).
13
-
14
- ## 🌟 Features
15
-
16
- - **BIP-39 Seed Phrase Support**: Generate and validate BIP-39 mnemonic seed phrases
17
- - **EVM Derivation Paths**: Support for BIP-44 standard derivation paths for Ethereum (m/44'/60')
18
- - **Multi-Account Management**: Create and manage multiple accounts from a single seed phrase
19
- - **Transaction Management**: Send transactions and get fee estimates with EIP-1559 support
20
- - **ERC20 Support**: Query native token and ERC20 token balances using smart contract interactions
16
+ For detailed documentation about the complete WDK ecosystem, visit [docs.wdk.tether.io](https://docs.wdk.tether.io).
21
17
 
22
18
  ## ⬇️ Installation
23
19
 
@@ -33,19 +29,34 @@ npm install @tetherto/wdk-wallet-evm
33
29
 
34
30
  ### Importing from `@tetherto/wdk-wallet-evm`
35
31
 
36
- ### Creating a New Wallet
32
+ ```javascript
33
+ import WalletManagerEvm, {
34
+ WalletAccountEvm,
35
+ WalletAccountReadOnlyEvm,
36
+ } from '@tetherto/wdk-wallet-evm'
37
+
38
+ // Signers are exported under the /signers subpath
39
+ import {
40
+ SeedSignerEvm,
41
+ PrivateKeySignerEvm,
42
+ } from '@tetherto/wdk-wallet-evm/signers'
43
+ ```
44
+
45
+ ### Create a Wallet Manager (seed-based)
37
46
 
38
47
  ```javascript
39
- import WalletManagerEvm, { WalletAccountEvm, WalletAccountReadOnlyEvm } from '@tetherto/wdk-wallet-evm'
48
+ import WalletManagerEvm from '@tetherto/wdk-wallet-evm'
40
49
 
41
50
  // Use a BIP-39 seed phrase (replace with your own secure phrase)
42
- const seedPhrase = 'test only example nut use this real life secret phrase must random'
51
+ const seedPhrase =
52
+ 'test only example nut use this real life secret phrase must random'
43
53
 
44
- // Create wallet manager with provider config
54
+ // Create the wallet manager straight from the seed (recommended: derivation
55
+ // paths are handled for you) with provider config (provider is required for chain ops)
45
56
  const wallet = new WalletManagerEvm(seedPhrase, {
46
57
  // Option 1: Using RPC URL
47
- provider: 'https://eth-mainnet.g.alchemy.com/v2/your-api-key', // or any EVM RPC endpoint
48
- transferMaxFee: 100000000000000 // Optional: Maximum fee in wei
58
+ provider: 'https://sepolia.drpc.org', // any EVM RPC
59
+ transferMaxFee: 100000000000000n, // Optional: max fee in wei (BigInt)
49
60
  })
50
61
 
51
62
  // OR
@@ -53,35 +64,67 @@ const wallet = new WalletManagerEvm(seedPhrase, {
53
64
  // Option 2: Using EIP-1193 provider (e.g., from browser wallet)
54
65
  const wallet2 = new WalletManagerEvm(seedPhrase, {
55
66
  provider: window.ethereum, // EIP-1193 provider
56
- transferMaxFee: 100000000000000 // Optional: Maximum fee in wei
67
+ transferMaxFee: 100000000000000n, // Optional
57
68
  })
58
69
 
59
70
  // Get a full access account
60
- const account = await wallet.getAccount(0)
71
+ const account0 = await wallet.getAccount(0)
61
72
 
62
73
  // Convert to a read-only account
63
- const readOnlyAccount = await account.toReadOnlyAccount()
74
+ const readOnlyAccount = await account0.toReadOnlyAccount()
75
+ ```
76
+
77
+ ### Single Account (no manager): Private key
78
+
79
+ ```javascript
80
+ import { WalletAccountEvm } from '@tetherto/wdk-wallet-evm'
81
+ import { PrivateKeySignerEvm } from '@tetherto/wdk-wallet-evm/signers'
82
+
83
+ // From a raw private key (hex string or bytes)
84
+ const pkSigner = new PrivateKeySignerEvm('0x0123...abcd')
85
+ const pkAccount = new WalletAccountEvm(pkSigner, {
86
+ provider: 'https://eth-mainnet.g.alchemy.com/v2/your-api-key',
87
+ })
88
+ ```
89
+
90
+ ### Single Account (no manager): Seed
91
+
92
+ ```javascript
93
+ import { WalletAccountEvm } from '@tetherto/wdk-wallet-evm'
94
+
95
+ // From a BIP-39 seed phrase (or seed bytes); derives the default account m/44'/60'/0'/0/0
96
+ const account = new WalletAccountEvm(mnemonic, {
97
+ provider: 'https://eth-mainnet.g.alchemy.com/v2/your-api-key',
98
+ })
99
+
100
+ // Or pick a specific account path, relative to m/44'/60'
101
+ const account5 = new WalletAccountEvm(mnemonic, "0'/0/5", {
102
+ provider: 'https://eth-mainnet.g.alchemy.com/v2/your-api-key',
103
+ })
64
104
  ```
65
105
 
66
- ### Managing Multiple Accounts
106
+ ### Managing Multiple Accounts (seed-based manager)
67
107
 
68
108
  ```javascript
69
109
  import WalletManagerEvm from '@tetherto/wdk-wallet-evm'
70
110
 
71
- // Assume wallet is already created
111
+ const wallet = new WalletManagerEvm(mnemonic, {
112
+ provider: 'https://eth-mainnet.g.alchemy.com/v2/your-api-key',
113
+ })
114
+
72
115
  // Get the first account (index 0)
73
- const account = await wallet.getAccount(0)
74
- const address = await account.getAddress()
116
+ const account = await wallet.getAccount(0) // m/44'/60'/0'/0/0
117
+ const address = await account.getAddress() // 0x...
75
118
  console.log('Account 0 address:', address)
76
119
 
77
120
  // Get the second account (index 1)
78
- const account1 = await wallet.getAccount(1)
79
- const address1 = await account1.getAddress()
121
+ const account1 = await wallet.getAccount(1) // m/44'/60'/0'/0/1
122
+ const address1 = await account1.getAddress() // 0x...
80
123
  console.log('Account 1 address:', address1)
81
124
 
82
125
  // Get account by custom derivation path
83
126
  // Full path will be m/44'/60'/0'/0/5
84
- const customAccount = await wallet.getAccountByPath("0'/0/5")
127
+ const customAccount = await wallet.getAccountByPath('0\'/0/5')
85
128
  const customAddress = await customAccount.getAddress()
86
129
  console.log('Custom account address:', customAddress)
87
130
 
@@ -96,17 +139,15 @@ console.log('Custom account address:', customAddress)
96
139
  For accounts where you have the seed phrase and full access:
97
140
 
98
141
  ```javascript
99
- import WalletManagerEvm from '@tetherto/wdk-wallet-evm'
100
-
101
142
  // Assume wallet and account are already created
102
143
  // Get native token balance (in wei)
103
144
  const balance = await account.getBalance()
104
145
  console.log('Native balance:', balance, 'wei') // 1 ETH = 1000000000000000000 wei
105
146
 
106
147
  // Get ERC20 token balance
107
- const tokenContract = '0x...'; // ERC20 contract address
108
- const tokenBalance = await account.getTokenBalance(tokenContract);
109
- console.log('Token balance:', tokenBalance);
148
+ const tokenContract = '0x...' // ERC20 contract address
149
+ const tokenBalance = await account.getTokenBalance(tokenContract)
150
+ console.log('Token balance:', tokenBalance)
110
151
 
111
152
  // Note: Provider is required for balance checks
112
153
  // Make sure wallet was created with a provider configuration
@@ -120,8 +161,9 @@ For addresses where you don't have the seed phrase:
120
161
  import { WalletAccountReadOnlyEvm } from '@tetherto/wdk-wallet-evm'
121
162
 
122
163
  // Create a read-only account
123
- const readOnlyAccount = new WalletAccountReadOnlyEvm('0x...', { // Ethereum address
124
- provider: 'https://eth-mainnet.g.alchemy.com/v2/your-api-key' // Required for balance checks
164
+ const readOnlyAccount = new WalletAccountReadOnlyEvm('0x...', {
165
+ // Ethereum address
166
+ provider: 'https://sepolia.drpc.org', // Required for balance checks
125
167
  })
126
168
 
127
169
  // Check native token balance
@@ -138,7 +180,7 @@ console.log('Token balance:', tokenBalance)
138
180
 
139
181
  ### Sending Transactions
140
182
 
141
- Send native tokens and estimate fees using `WalletAccountEvm`. Supports EIP-1559 fee model.
183
+ Send native tokens and estimate fees using `WalletAccountEvm`. Supports EIP-1559 and auto-populates gas/fee fields where possible.
142
184
 
143
185
  ```javascript
144
186
  // Send native tokens
@@ -146,8 +188,8 @@ Send native tokens and estimate fees using `WalletAccountEvm`. Supports EIP-1559
146
188
  const result = await account.sendTransaction({
147
189
  to: '0x...', // Recipient address
148
190
  value: 1000000000000000000n, // 1 ETH in wei
149
- maxFeePerGas: 30000000000, // Optional: max fee per gas (in wei)
150
- maxPriorityFeePerGas: 2000000000 // Optional: max priority fee per gas (in wei)
191
+ maxFeePerGas: 30000000000n, // Optional: max fee per gas (in wei)
192
+ maxPriorityFeePerGas: 2000000000n, // Optional: max priority fee per gas (in wei)
151
193
  })
152
194
  console.log('Transaction hash:', result.hash)
153
195
  console.log('Transaction fee:', result.fee, 'wei')
@@ -157,15 +199,15 @@ const legacyResult = await account.sendTransaction({
157
199
  to: '0x...',
158
200
  value: 1000000000000000000n,
159
201
  gasPrice: 20000000000n, // Optional: legacy gas price (in wei)
160
- gasLimit: 21000 // Optional: gas limit
202
+ gasLimit: 21000, // Optional: gas limit
161
203
  })
162
204
 
163
205
  // Get transaction fee estimate
164
206
  const quote = await account.quoteSendTransaction({
165
207
  to: '0x...',
166
- value: 1000000000000000000n
167
- });
168
- console.log('Estimated fee:', quote.fee, 'wei');
208
+ value: 1000000000000000000n,
209
+ })
210
+ console.log('Estimated fee:', quote.fee, 'wei')
169
211
  ```
170
212
 
171
213
  ### Token Transfers
@@ -175,25 +217,38 @@ Transfer ERC20 tokens and estimate fees using `WalletAccountEvm`. Uses standard
175
217
  ```javascript
176
218
  // Transfer ERC20 tokens
177
219
  const transferResult = await account.transfer({
178
- token: '0x...', // ERC20 contract address
179
- recipient: '0x...', // Recipient's address
180
- amount: 1000000n // Amount in token's base units (use BigInt for large numbers)
181
- });
182
- console.log('Transfer hash:', transferResult.hash);
183
- console.log('Transfer fee:', transferResult.fee, 'wei');
220
+ token: '0x...', // ERC20 contract address
221
+ recipient: '0x...', // Recipient's address
222
+ amount: 1000000n, // Amount in token's base units (use BigInt for large numbers)
223
+ })
224
+ console.log('Transfer hash:', transferResult.hash)
225
+ console.log('Transfer fee:', transferResult.fee, 'wei')
184
226
 
185
227
  // Quote token transfer fee
186
228
  const transferQuote = await account.quoteTransfer({
187
- token: '0x...', // ERC20 contract address
188
- recipient: '0x...', // Recipient's address
189
- amount: 1000000n // Amount in token's base units
229
+ token: '0x...', // ERC20 contract address
230
+ recipient: '0x...', // Recipient's address
231
+ amount: 1000000n, // Amount in token's base units
190
232
  })
191
233
  console.log('Transfer fee estimate:', transferQuote.fee, 'wei')
192
234
  ```
193
235
 
236
+ ### Token Approvals
237
+
238
+ Approve a spender for a specific amount (uses ERC20 `approve`):
239
+
240
+ ```javascript
241
+ const approval = await account.approve({
242
+ token: '0x...', // ERC20 contract
243
+ spender: '0x...', // Spender address
244
+ amount: 1000000n, // Allowance amount in base units
245
+ })
246
+ console.log('Approval tx hash:', approval.hash)
247
+ ```
248
+
194
249
  ### Message Signing and Verification
195
250
 
196
- Sign and verify messages using `WalletAccountEvm`.
251
+ Sign messages using `WalletAccountEvm` and verify signatures using `WalletAccountReadOnlyEvm`.
197
252
 
198
253
  ```javascript
199
254
  // Sign a message
@@ -201,8 +256,8 @@ const message = 'Hello, Ethereum!'
201
256
  const signature = await account.sign(message)
202
257
  console.log('Signature:', signature)
203
258
 
204
- // Verify a signature
205
- const isValid = await account.verify(message, signature)
259
+ // Verify a signature (can use read-only account)
260
+ const isValid = await readOnlyAccount.verify(message, signature)
206
261
  console.log('Signature valid:', isValid)
207
262
  ```
208
263
 
@@ -212,9 +267,9 @@ Retrieve current fee rates using `WalletManagerEvm`. Supports EIP-1559 fee model
212
267
 
213
268
  ```javascript
214
269
  // Get current fee rates
215
- const feeRates = await wallet.getFeeRates();
216
- console.log('Normal fee rate:', feeRates.normal, 'wei'); // 1.1x base fee
217
- console.log('Fast fee rate:', feeRates.fast, 'wei'); // 2.0x base fee
270
+ const feeRates = await wallet.getFeeRates()
271
+ console.log('Normal fee rate:', feeRates.normal, 'wei') // 1.1x base fee
272
+ console.log('Fast fee rate:', feeRates.fast, 'wei') // 2.0x base fee
218
273
  ```
219
274
 
220
275
  ### Memory Management
@@ -229,192 +284,90 @@ account.dispose()
229
284
  wallet.dispose()
230
285
  ```
231
286
 
232
- ## 📚 API Reference
233
-
234
- ### Table of Contents
235
-
236
- ### Table of Contents
237
-
238
- | Class | Description | Methods |
239
- |-------|-------------|---------|
240
- | [WalletManagerEvm](#walletmanagerevm) | Main class for managing EVM wallets. Extends `WalletManager` from `@tetherto/wdk-wallet`. | [Constructor](#constructor), [Methods](#methods) |
241
- | [WalletAccountEvm](#walletaccountevm) | Individual EVM wallet account implementation. Extends `WalletAccountReadOnlyEvm` and implements `IWalletAccount` from `@tetherto/wdk-wallet`. | [Constructor](#constructor-1), [Methods](#methods-1), [Properties](#properties) |
242
- | [WalletAccountReadOnlyEvm](#walletaccountreadonlyevm) | Read-only EVM wallet account. Extends `WalletAccountReadOnly` from `@tetherto/wdk-wallet`. | [Constructor](#constructor-2), [Methods](#methods-2) |
243
-
244
- ### WalletManagerEvm
245
-
246
- The main class for managing EVM wallets.
247
- Extends `WalletManager` from `@tetherto/wdk-wallet`.
248
-
249
- #### Constructor
250
-
251
- ```javascript
252
- new WalletManagerEvm(seed, config)
253
- ```
254
-
255
- **Parameters:**
256
- - `seed` (string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytes
257
- - `config` (object, optional): Configuration object
258
- - `provider` (string | Eip1193Provider): RPC endpoint URL or EIP-1193 provider instance
259
- - `transferMaxFee` (number | bigint, optional): Maximum fee amount for transfer operations (in wei)
260
-
261
- **Example:**
262
- ```javascript
263
- const wallet = new WalletManagerEvm(seedPhrase, {
264
- provider: 'https://eth-mainnet.g.alchemy.com/v2/your-api-key',
265
- transferMaxFee: '100000000000000' // Maximum fee in wei
266
- })
267
- ```
268
-
269
- #### Methods
287
+ ## 🔐 Signers (advanced usage)
270
288
 
271
- | Method | Description | Returns |
272
- |--------|-------------|---------|
273
- | `getAccount(index)` | Returns a wallet account at the specified index | `Promise<WalletAccountEvm>` |
274
- | `getAccountByPath(path)` | Returns a wallet account at the specified BIP-44 derivation path | `Promise<WalletAccountEvm>` |
275
- | `getFeeRates()` | Returns current fee rates for transactions | `Promise<{normal: bigint, fast: bigint}>` |
276
- | `dispose()` | Disposes all wallet accounts, clearing private keys from memory | `void` |
289
+ Signers provide the cryptographic primitives for accounts. The recommended way to use this package is passing the seed straight to `WalletManagerEvm` or `WalletAccountEvm` (as in the sections above); constructing your own signer is considered advanced usage. There are two signer implementations:
277
290
 
278
- ### WalletAccountEvm
291
+ - **SeedSignerEvm**: Holds one HD node from a BIP-39 seed at any absolute BIP-32 path (default: `"m/44'/60'"`) and derives child signers relative to its own path. Always derivable.
292
+ - **PrivateKeySignerEvm**: Wraps a raw private key in a memory-safe buffer. Cannot derive. Use directly with `WalletAccountEvm`. Not supported as `WalletManagerEvm`'s default signer (registrable by name via `addSigner`).
279
293
 
280
- Represents an individual wallet account. Implements `IWalletAccount` from `@tetherto/wdk-wallet`.
281
-
282
- #### Constructor
294
+ Examples:
283
295
 
284
296
  ```javascript
285
- new WalletAccountEvm(seed, path, config)
286
- ```
287
-
288
- **Parameters:**
289
- - `seed` (string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytes
290
- - `path` (string): BIP-44 derivation path (e.g., "0'/0/0")
291
- - `config` (object, optional): Configuration object
292
- - `provider` (string | Eip1193Provider): RPC endpoint URL or EIP-1193 provider instance
293
- - `transferMaxFee` (number | bigint, optional): Maximum fee amount for transfer operations (in wei)
294
-
295
- #### Methods
296
-
297
- | Method | Description | Returns |
298
- |--------|-------------|---------|
299
- | `getAddress()` | Returns the account's address | `Promise<string>` |
300
- | `sign(message)` | Signs a message using the account's private key | `Promise<string>` |
301
- | `verify(message, signature)` | Verifies a message signature | `Promise<boolean>` |
302
- | `sendTransaction(tx)` | Sends an EVM transaction | `Promise<{hash: string, fee: bigint}>` |
303
- | `quoteSendTransaction(tx)` | Estimates the fee for an EVM transaction | `Promise<{fee: bigint}>` |
304
- | `transfer(options)` | Transfers ERC20 tokens to another address | `Promise<{hash: string, fee: bigint}>` |
305
- | `quoteTransfer(options)` | Estimates the fee for an ERC20 transfer | `Promise<{fee: bigint}>` |
306
- | `getBalance()` | Returns the native token balance (in wei) | `Promise<bigint>` |
307
- | `getTokenBalance(tokenAddress)` | Returns the balance of a specific ERC20 token | `Promise<bigint>` |
308
- | `dispose()` | Disposes the wallet account, clearing private keys from memory | `void` |
297
+ import WalletManagerEvm, { WalletAccountEvm } from '@tetherto/wdk-wallet-evm'
298
+ import { SeedSignerEvm, PrivateKeySignerEvm } from '@tetherto/wdk-wallet-evm/signers'
309
299
 
310
- ##### `sendTransaction(tx)`
311
- Sends an EVM transaction.
300
+ // Manager from your own signer. The default path "m/44'/60'" works out of the box:
301
+ // accounts derive below the signer's own path (getAccount(0) -> m/44'/60'/0'/0/0)
302
+ const wallet = new WalletManagerEvm(new SeedSignerEvm(mnemonic), { provider: 'https://...' })
312
303
 
313
- **Parameters:**
314
- - `tx` (object): The transaction object
315
- - `to` (string): Recipient address
316
- - `value` (number | bigint): Amount in wei
317
- - `data` (string, optional): Transaction data in hex format
318
- - `gasLimit` (number | bigint, optional): Maximum gas units
319
- - `gasPrice` (number | bigint, optional): Legacy gas price in wei
320
- - `maxFeePerGas` (number | bigint, optional): EIP-1559 max fee per gas in wei
321
- - `maxPriorityFeePerGas` (number | bigint, optional): EIP-1559 max priority fee per gas in wei
304
+ // Account from your own signer: derive the account below the signer's default path
305
+ const signer = await new SeedSignerEvm(mnemonic).derive("0'/0/0")
306
+ const account = new WalletAccountEvm(signer, { provider: 'https://...' })
322
307
 
323
- **Returns:** `Promise<{hash: string, fee: bigint}>` - Object containing hash and fee (in wei)
324
-
325
- #### Properties
326
-
327
- | Property | Type | Description |
328
- |----------|------|-------------|
329
- | `index` | `number` | The derivation path's index of this account |
330
- | `path` | `string` | The full derivation path of this account |
331
- | `keyPair` | `object` | The account's key pair (⚠️ Contains sensitive data) |
332
-
333
- ⚠️ **Security Note**: The `keyPair` property contains sensitive cryptographic material. Never log, display, or expose the private key.
334
-
335
- ### WalletAccountReadOnlyEvm
336
-
337
- Represents a read-only wallet account.
338
-
339
- #### Constructor
340
-
341
- ```javascript
342
- new WalletAccountReadOnlyEvm(address, config)
308
+ // Single account from a private key
309
+ const pkAccount = new WalletAccountEvm(new PrivateKeySignerEvm('0x0123...'), { provider: 'https://...' })
343
310
  ```
344
311
 
345
- **Parameters:**
346
- - `address` (string): The account's address
347
- - `config` (object, optional): Configuration object
348
- - `provider` (string | Eip1193Provider): RPC endpoint URL or EIP-1193 provider instance
349
-
350
- #### Methods
351
-
352
- | Method | Description | Returns |
353
- |--------|-------------|---------|
354
- | `getBalance()` | Returns the native token balance (in wei) | `Promise<bigint>` |
355
- | `getTokenBalance(tokenAddress)` | Returns the balance of a specific ERC20 token | `Promise<bigint>` |
356
- | `quoteSendTransaction(tx)` | Estimates the fee for an EVM transaction | `Promise<{fee: bigint}>` |
357
- | `quoteTransfer(options)` | Estimates the fee for an ERC20 transfer | `Promise<{fee: bigint}>` |
312
+ Notes for advanced usage: a `SeedSignerEvm` sits exactly at the path you give it, and both `derive` and the manager's `getAccount`/`getAccountByPath` work relative to that path. If you rely on a non-default tree, pass your own absolute path explicitly (e.g. `new SeedSignerEvm(mnemonic, "m/44'/61'")`) so the resulting account positions are the ones you expect.
358
313
 
359
- ## 🌐 Supported Networks
314
+ ## Key Capabilities
360
315
 
361
- This package works with any EVM-compatible blockchain, including:
316
+ - **BIP-39 Seed Phrase Support**: Generate and validate mnemonic seed phrases
317
+ - **BIP-44 Derivation Paths**: Standard Ethereum derivation (m/44'/60')
318
+ - **Multi-Account Management**: Derive multiple accounts from a single seed phrase
319
+ - **EIP-1559 Transaction Support**: Modern fee estimation and transaction sending
320
+ - **ERC-20 Token Support**: Query balances and transfer tokens
321
+ - **Message Signing**: Sign and verify messages (EIP-191 and EIP-712)
322
+ - **Fee Estimation**: Real-time network fee rates with normal/fast tiers
323
+ - **Secure Memory Disposal**: Clear private keys from memory when done
324
+ - **Signer Submodule**: Create your own signer from ISignerEvm, support for Seed and Private key signers
325
+ - **EIP-7702 Delegation**: Delegate EOAs to smart contracts, sign authorizations, and send type 4 transactions
362
326
 
363
- - **Ethereum Mainnet**
364
- - **Ethereum Testnets** (Sepolia, etc.)
365
- - **Layer 2 Networks** (Arbitrum, Optimism, etc.)
366
- - **Other EVM Chains** (Polygon, Avalanche C-Chain, etc.)
327
+ ## Compatibility
367
328
 
368
- ## 🔒 Security Considerations
329
+ - **Ethereum Mainnet** and testnets (Sepolia)
330
+ - **Layer 2 Networks**: Arbitrum, Optimism, Base
331
+ - **Other EVM Chains**: Polygon, Avalanche C-Chain, and any EVM-compatible chain
369
332
 
370
- - **Seed Phrase Security**: Always store your seed phrase securely and never share it
371
- - **Private Key Management**: The package handles private keys internally with memory safety features
372
- - **Provider Security**: Use trusted RPC endpoints and consider running your own node for production
373
- - **Transaction Validation**: Always validate transaction details before signing
374
- - **Memory Cleanup**: Use the `dispose()` method to clear private keys from memory when done
375
- - **Fee Limits**: Set `transferMaxFee` in config to prevent excessive transaction fees
376
- - **Gas Estimation**: Always estimate gas before sending transactions
377
- - **EIP-1559**: Consider using EIP-1559 fee model for better gas price estimation
378
- - **Contract Interactions**: Verify contract addresses and token decimals before transfers
333
+ ## Documentation
379
334
 
380
- ## 🛠️ Development
335
+ | Topic | Description | Link |
336
+ | ------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------- |
337
+ | Overview | Module overview and feature summary | [Wallet EVM Overview](https://docs.wdk.tether.io/sdk/wallet-modules/wallet-evm) |
338
+ | Usage | End-to-end integration walkthrough | [Wallet EVM Usage](https://docs.wdk.tether.io/sdk/wallet-modules/wallet-evm/usage) |
339
+ | Configuration | Provider, fees, and network configuration | [Wallet EVM Configuration](https://docs.wdk.tether.io/sdk/wallet-modules/wallet-evm/configuration) |
340
+ | API Reference | Complete class and type reference | [Wallet EVM API Reference](https://docs.wdk.tether.io/sdk/wallet-modules/wallet-evm/api-reference) |
381
341
 
382
- ### Building
342
+ ## Examples
383
343
 
384
- ```bash
385
- # Install dependencies
386
- npm install
387
-
388
- # Build TypeScript definitions
389
- npm run build:types
390
-
391
- # Lint code
392
- npm run lint
393
-
394
- # Fix linting issues
395
- npm run lint:fix
396
- ```
344
+ | Example | Description |
345
+ | ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
346
+ | [Create Wallet](https://github.com/tetherto/wdk-examples/blob/main/wallet-evm/create-wallet.ts) | Initialize a wallet manager and derive accounts from a seed phrase |
347
+ | [Manage Accounts](https://github.com/tetherto/wdk-examples/blob/main/wallet-evm/manage-accounts.ts) | Work with multiple accounts and custom derivation paths |
348
+ | [Check Balances](https://github.com/tetherto/wdk-examples/blob/main/wallet-evm/check-balances.ts) | Query native token and ERC-20 balances for owned accounts |
349
+ | [Read-Only Account](https://github.com/tetherto/wdk-examples/blob/main/wallet-evm/read-only-account.ts) | Monitor balances for any address without a private key |
350
+ | [Send Transaction](https://github.com/tetherto/wdk-examples/blob/main/wallet-evm/send-transaction.ts) | Estimate fees and send native token transactions (EIP-1559 + legacy) |
351
+ | [Token Transfer](https://github.com/tetherto/wdk-examples/blob/main/wallet-evm/token-transfer.ts) | Transfer ERC-20 tokens and estimate transfer fees |
352
+ | [Sign & Verify Message](https://github.com/tetherto/wdk-examples/blob/main/wallet-evm/sign-verify-message.ts) | Sign messages and verify signatures |
353
+ | [Fee Management](https://github.com/tetherto/wdk-examples/blob/main/wallet-evm/fee-management.ts) | Retrieve current network fee rates |
354
+ | [Memory Management](https://github.com/tetherto/wdk-examples/blob/main/wallet-evm/memory-management.ts) | Securely dispose wallets and clear private keys from memory |
397
355
 
398
- ### Testing
356
+ > For detailed walkthroughs, see the [Usage Guide](https://docs.wdk.tether.io/sdk/wallet-modules/wallet-evm/usage).
357
+ > See all runnable examples in the [wdk-examples](https://github.com/tetherto/wdk-examples) repository.
399
358
 
400
- ```bash
401
- # Run tests
402
- npm test
359
+ ## Community
403
360
 
404
- # Run tests with coverage
405
- npm run test:coverage
406
- ```
361
+ Join the [WDK Discord](https://discord.gg/arYXDhHB2w) to connect with other developers.
407
362
 
408
- ## 📜 License
363
+ ## Support
409
364
 
410
- This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
365
+ For support, please [open an issue](https://github.com/tetherto/wdk-wallet-evm/issues) on GitHub or reach out via [email](mailto:wallet-info@tether.io).
411
366
 
412
- ## 🤝 Contributing
367
+ ## Contributing
413
368
 
414
369
  Contributions are welcome! Please feel free to submit a Pull Request.
415
370
 
416
- ## 🆘 Support
371
+ ## License
417
372
 
418
- For support, please open an issue on the GitHub repository.
419
-
420
- ---
373
+ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
package/bare.js CHANGED
@@ -13,8 +13,8 @@
13
13
  // limitations under the License.
14
14
  'use strict'
15
15
 
16
- import 'bare-wdk-runtime'
16
+ import 'bare-node-runtime/global'
17
17
 
18
- export * from './index.js' with { imports: 'bare-wdk-runtime/package' }
18
+ export * from './index.js' with { imports: 'bare-node-runtime/imports' }
19
19
 
20
- export { default } from './index.js' with { imports: 'bare-wdk-runtime/package' }
20
+ export { default } from './index.js' with { imports: 'bare-node-runtime/imports' }
@@ -1,9 +1,10 @@
1
- require('@nomicfoundation/hardhat-ethers')
2
-
3
1
  /** @type {import('hardhat/config').HardhatUserConfig} */
4
- module.exports = {
2
+ export default {
5
3
  networks: {
6
4
  hardhat: {
5
+ type: 'edr-simulated',
6
+ chainId: 1,
7
+ hardfork: 'prague',
7
8
  accounts: {
8
9
  mnemonic: 'anger burst story spy face pattern whale quit delay fiction ball solve',
9
10
  path: "m/44'/60'/0'/0",