Skip to content

Commit 66b5373

Browse files
authored
Merge pull request #195 from etherspot/feat/owner-account-param
feat/owner-account-param
2 parents 44d06f8 + d39104e commit 66b5373

8 files changed

Lines changed: 451 additions & 171 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [2.1.2] - 2025-01-27
4+
5+
### Added Changes
6+
7+
- **viemLocalAccount Support**: Added support for passing a `LocalAccount` (from viem) directly to the Transaction Kit via the `viemLocalAccount` parameter in `delegatedEoa` mode. This allows users to bypass `privateKeyToAccount` conversion when they already have a `LocalAccount` object. The `viemLocalAccount` parameter works equivalently to `privateKey` and provides the same functionality - users can provide either `privateKey` or `viemLocalAccount`, but not both.
8+
39
## [2.1.1] - 2025-01-27
410

511
### Added Changes

README.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ import { TransactionKit } from '@etherspot/transaction-kit';
114114
// Initialize TransactionKit
115115
const kit = TransactionKit({
116116
chainId: 137, // Polygon mainnet
117-
privateKey: '0x...your-private-key...', // Required for EIP-7702
117+
privateKey: '0x...your-private-key...', // Required for EIP-7702 (either privateKey or viemLocalAccount)
118118
bundlerApiKey: 'your-bundler-api-key', // Optional but recommended
119119
walletMode: 'delegatedEoa', // Required for EIP-7702
120120
});
@@ -240,7 +240,7 @@ For EIP-7702 specific functionalities:
240240
// Initialize with delegated EOA mode
241241
const kit = TransactionKit({
242242
chainId: 137, // Polygon
243-
privateKey: '0x...your-private-key...',
243+
privateKey: '0x...your-private-key...', // Required for EIP-7702 (either privateKey or viemLocalAccount)
244244
bundlerApiKey: 'your-bundler-api-key',
245245
walletMode: 'delegatedEoa',
246246
});
@@ -361,6 +361,7 @@ const result = await kit.sendBatches({ authorization });
361361
```
362362

363363
Notes:
364+
364365
- The `authorization` must match the transaction `chainId` and Kernel v3.3 implementation.
365366
- For multi-chain batches, the `authorization` will only be applied to chain groups matching the authorization's `chainId`.
366367
- `authorization` is only supported in `delegatedEoa` mode; using it in `modular` mode will cause validation errors.
@@ -436,7 +437,7 @@ Advanced EIP-7702 functionality with delegated Externally Owned Accounts:
436437
```typescript
437438
const kit = TransactionKit({
438439
chainId: 137, // Required: Default chain ID
439-
privateKey: '0x...your-private-key...', // Required: EOA private key
440+
privateKey: '0x...your-private-key...', // Required for EIP-7702 (either privateKey or viemLocalAccount)
440441
bundlerApiKey: 'your-api-key', // Optional: For better performance
441442
bundlerUrl: 'https://your-bundler-url.com', // Optional: Custom bundler URL
442443
bundlerApiKeyFormat: '?api-key=', // Optional: API key format (default: '?api-key=')
@@ -445,21 +446,21 @@ const kit = TransactionKit({
445446
});
446447
```
447448

448-
**Note**: In delegated EOA mode, you don't need to provide a `provider` as the private key is used directly to create the account.
449+
**Note**: In delegated EOA mode, you don't need to provide a `provider`. You can provide either a `privateKey` or a `viemLocalAccount` (a `LocalAccount` from viem) directly, but not both. The `viemLocalAccount` option is useful when you already have a `LocalAccount` object and want to bypass the `privateKey` conversion.
449450

450451
### Wallet Mode Comparison
451452

452-
| Feature | Modular Mode | Delegated EOA Mode |
453-
| --------------------------- | ------------------------ | ---------------------------------- |
454-
| **Account Type** | Etherspot Smart Account | EIP-7702 Delegated EOA |
455-
| **Provider Required** | ✅ Yes (wallet provider) | ❌ No (uses private key) |
456-
| **Private Key Required** | ❌ No | ✅ Yes |
457-
| **Client-Side Safe** | ✅ Yes | ⚠️ Depends on private key handling |
458-
| **Paymaster Support** | ✅ Full support | ⚠️ Not yet supported |
459-
| **UserOp Overrides** | ✅ Supported | ⚠️ Not yet supported |
460-
| **EIP-7702 Methods** | ❌ Not available | ✅ Yes |
461-
| **Modular SDK Integration** | ✅ Yes | ❌ No |
462-
| **ZeroDev Integration** | ❌ No | ✅ Yes integration |
453+
| Feature | Modular Mode | Delegated EOA Mode |
454+
| -------------------------------------- | ------------------------ | ---------------------------------------------- |
455+
| **Account Type** | Etherspot Smart Account | EIP-7702 Delegated EOA |
456+
| **Provider Required** | ✅ Yes (wallet provider) | ❌ No (uses privateKey or viemLocalAccount) |
457+
| **Private Key/Owner Account Required** | ❌ No | ✅ Yes (either privateKey or viemLocalAccount) |
458+
| **Client-Side Safe** | ✅ Yes | ⚠️ Depends on private key/account handling |
459+
| **Paymaster Support** | ✅ Full support | ⚠️ Not yet supported |
460+
| **UserOp Overrides** | ✅ Supported | ⚠️ Not yet supported |
461+
| **EIP-7702 Methods** | ❌ Not available | ✅ Yes |
462+
| **Modular SDK Integration** | ✅ Yes | ❌ No |
463+
| **ZeroDev Integration** | ❌ No | ✅ Yes integration |
463464

464465
### Advanced Bundler Configuration
465466

@@ -512,7 +513,7 @@ if (kit.getEtherspotProvider().getWalletMode() === 'delegatedEoa') {
512513

513514
// Get account instances (delegatedEoa mode only)
514515
const delegatedEoaAccount = await kit.getDelegatedEoaAccount(137);
515-
const ownerAccount = await kit.getOwnerAccount(137);
516+
const viemLocalAccount = await kit.getOwnerAccount(137);
516517
}
517518

518519
// Get transaction hash from userOp hash (available in both modes)
@@ -574,11 +575,11 @@ When calling `delegateSmartAccountToEoa({ delegateImmediately: false })`, the me
574575

575576
## 🔒 Security Considerations
576577

577-
### Private Key Handling in Delegated EOA Mode
578+
### Private Key and Owner Account Handling in Delegated EOA Mode
578579

579-
When using `walletMode: 'delegatedEoa'`, you must provide a private key. Here are important security considerations:
580+
When using `walletMode: 'delegatedEoa'`, you must provide either a `privateKey` or a `viemLocalAccount` (LocalAccount from viem). Here are important security considerations:
580581

581-
**⚠️ Never expose private keys in client-side code or logs!**
582+
**⚠️ Never expose private keys or owner accounts in client-side code or logs!**
582583

583584
```typescript
584585
// ❌ BAD: Hardcoded private key
@@ -593,7 +594,7 @@ const kit = TransactionKit({
593594
walletMode: 'delegatedEoa',
594595
});
595596

596-
// ✅ GOOD: Use secure key management
597+
// ✅ GOOD: Use secure key management (works with both privateKey and viemLocalAccount)
597598
const kit = TransactionKit({
598599
privateKey: await getSecurePrivateKey(), // From secure storage
599600
walletMode: 'delegatedEoa',
@@ -602,20 +603,21 @@ const kit = TransactionKit({
602603

603604
**Best Practices:**
604605

605-
1. **Private Key Security**: Handle private keys securely - never hardcode them in client-side code
606+
1. **Private Key/Owner Account Security**: Handle private keys and owner accounts securely - never hardcode them in client-side code
606607
2. **Environment Variables**: Store private keys in environment variables, never in code
607608
3. **Key Rotation**: Regularly rotate private keys for enhanced security
608-
4. **Access Control**: Implement proper access controls around private key usage
609+
4. **Access Control**: Implement proper access controls around private key and owner account usage
609610
5. **Audit Logging**: Log all transactions for security auditing
610611
6. **Secure Storage**: Use hardware security modules (HSM) or secure key management services for production
612+
7. **Owner Account Usage**: When using `viemLocalAccount`, ensure the underlying private key is handled securely
611613

612614
### Important Limitations & Considerations
613615

614616
#### Delegated EOA Mode Limitations
615617

616618
- **Paymaster Support**: Currently not supported in delegated EOA mode
617619
- **UserOp Overrides**: Custom userOp overrides are not yet supported
618-
- **Private Key Security**: Requires careful private key handling
620+
- **Private Key/Owner Account Security**: Requires careful private key or owner account handling
619621
- **ZeroDev Dependency**: Requires `@zerodev/sdk` package
620622

621623
#### Modular Mode Limitations

0 commit comments

Comments
 (0)