## Title Add ERC-4337 UserOperation type and encoding ## Labels `enhancement`, `account-abstraction`, `erc-4337` ## Description Implement the core `UserOperation` struct according to [ERC-4337 specification](https://eips.ethereum.org/EIPS/eip-4337) to enable account abstraction functionality, similar to [viem's implementation](https://github.com/wevm/viem/tree/main/src/account-abstraction). ## Requirements ### Core Type - [ ] Define `UserOperation` struct with all ERC-4337 required fields: - `sender: Address` - Account making the operation - `nonce: u256` - Anti-replay parameter (now using native u256!) - `init_code: []u8` - Account creation code (for first tx) - `call_data: []u8` - Data to pass to sender during execution - `call_gas_limit: u256` - Gas limit for main execution call - `verification_gas_limit: u256` - Gas for account validation - `pre_verification_gas: u256` - Fixed gas overhead - `max_fee_per_gas: u256` - Max fee per gas unit (EIP-1559) - `max_priority_fee_per_gas: u256` - Max priority fee (EIP-1559) - `paymaster_and_data: []u8` - Paymaster address and extra data - `signature: []u8` - Signature over the userOp hash ### Encoding & Hashing - [ ] Implement packed ABI encoding for UserOperation - [ ] Add `getUserOpHash(op: UserOperation, entry_point: Address, chain_id: u64) Hash` - [ ] Add `packUserOp(op: UserOperation) []u8` for encoding ### Helper Methods - [ ] `init()` - Create new UserOperation - [ ] `deinit()` - Free allocated memory - [ ] `isDeployment()` - Check if this deploys a new account (has init_code) ## File Structure ``` src/account_abstraction/ ├── user_operation.zig # Core UserOperation type ├── types.zig # AA-related types └── root.zig # Module exports ``` ## References - ERC-4337: https://eips.ethereum.org/EIPS/eip-4337 - Viem: https://github.com/wevm/viem/tree/main/src/account-abstraction - Account Abstraction contracts: https://github.com/eth-infinitism/account-abstraction ## Benefits - Enable gasless transactions - Smart contract wallet support - Batch operations - Session keys and permissions - Social recovery
Activity