Advanced
Account Abstraction (ERC-4337) — Hands-on lab
Build smart wallets.
Developer Advanced
6/8 — Account Abstraction (ERC-4337) — Hands-on lab
SimulateCraft userOps, sign them, run through a local bundler/entry point; flip paymaster rules to see reverts.
The root problem with conventional currency is all the trust that’s required to make it work.
ObserveLog userOpHash, nonce, and paymaster data to debug acceptance/rejection.
{
"sender": "0xWallet",
"nonce": "0x0",
"initCode": "0x",
"callData": "0x1234...", // your call
"callGasLimit": "0x100000",
"verificationGasLimit": "0x80000",
"preVerificationGas": "0x21000",
"maxFeePerGas": "0x59682f0f",
"maxPriorityFeePerGas": "0x3b9aca00",
"paymasterAndData": "0x"
}
// Quick Foundry-style script to sign and send a userOp hash
UserOperation memory op = buildUserOp();
bytes32 opHash = entryPoint.getUserOpHash(op);
(uint8 v, bytes32 r, bytes32 s) = vm.sign(ownerPk, opHash);
op.signature = abi.encodePacked(r, s, v);
entryPoint.handleOps(userOps, payable(msg.sender));
Scripted submissions make it easy to toggle bad nonce/sig/paymaster data and watch validateUserOp fail or pass.
Steps
- Generate a userOp with:CallData to a simple function; sign and submit to a local bundler.
- Alter the nonce or:Signature and confirm validateUserOp reverts.
- Attach a paymaster; set:A budget and see how maxGas/maxFee affect cost.
- Batch two calls in:One userOp; confirm atomicity and gas accounting.
- Log events for validation:Success/failure and paymaster sponsorship.