ERC-4337: Payment, validation and Deployment
How to pay for your transaction, validate your transaction and deploy your AA contract in ERC-4337
Apr 24 2023 | POPOP Taipei
Equal access to the Tokenized World
Nic Lin
imToken Labs
How to pay for your transaction in ERC-4337?
How to pay for your transaction in ERC-4337?
User
Bundler
ETH
ERC20
❌
Proposer
ETH
How to pay for your transaction in ERC-4337?
User
Bundler
ETH
Entrypoint
ETH
How to pay for your transaction in ERC-4337?
User
Entrypoint
ETH
depositTo(User)
ETH
How to pay for your transaction in ERC-4337?
User
Gas price I’m willing to pay
Max gas for my execution
Max gas for validating my transaction
Gas for Entrypoint processing overhead
How to pay for your transaction in ERC-4337?
Entrypoint
User
User’s AA contract
validateUserOp(...)
ETH
Your deposit not enough, please deposit
How to pay for your transaction in ERC-4337?
Entrypoint
User
User’s AA contract
validateUserOp(...)
ETH
Your deposit not enough, please deposit
Bundler
This is my UserOp, I’m willing to pay��`maxFeePerGas * (callGasLimit + verificationGasLimit + preVerificationGas)` ��ETH for this op.
How to pay for your transaction in ERC-4337?
How to validate your transaction in ERC-4337?
How to validate your transaction in ERC-4337?
Entrypoint
User’s AA contract
validateUserOp(...)
returns 0
User authorized 👍
Entrypoint
User’s AA contract
validateUserOp(...)
returns 1 or revert
User did NOT authorize 👎
How to validate your transaction in ERC-4337?
Entrypoint
User’s AA contract
validateUserOp(...)
returns 0
Signature checked.
User authorized 👍
ECDSA
How to validate your transaction in ERC-4337?
Entrypoint
User’s AA contract
validateUserOp(...)
returns 0
User authorized 👍
execute(...)
How to validate your transaction in ERC-4337?
Entrypoint
User’s AA contract
execute(...)
Entrypoint want me to execute, it must have called validateUserOp already
swap
How to validate your transaction in ERC-4337?
User’s AA contract
execute(...)
You are not Entrypoint
❌
How to validate your transaction in ERC-4337?
How to deploy your AA contract in ERC-4337?
How to deploy your AA contract in ERC-4337?
How to deploy your AA contract in ERC-4337?
How to deploy your AA contract in ERC-4337?
How to deploy your AA contract in ERC-4337?
Entrypoint
User
User’s AA contract
Please execute my UserOp
check contract exists
Not exist
How to deploy your AA contract in ERC-4337?
Entrypoint
User
Please deploy my AA contract and execute my UserOp
deploy
Already exist
User’s AA contract
How to deploy your AA contract in ERC-4337?
Entrypoint
User
Please deploy my AA contract, this is the factory address and data to call the factory for my contract deployment
Factory of user’s AA contract
How to deploy your AA contract in ERC-4337?
User
In the initcode field of my UserOp:
UserOp {
…
initcode: [20 bytes factory address][calldata for factory]
…
}
How to deploy your AA contract in ERC-4337?
UserOp {
…
initcode: [20 bytes factory address][calldata for factory]
…
}
For example:
ABI encode of “createAccount(owner,salt)”
How to deploy your AA contract in ERC-4337?
Entrypoint
Bob
Please deploy my AA contract and execute my UserOp
deploy
This is not Bob’s AA contract
Alice’s AA contract
How to deploy your AA contract in ERC-4337?
Bob
Where will my contract be deployed at?
Factory of Bob’s AA contract
getAddress(owner,salt)
How to deploy your AA contract in ERC-4337?
Bob
Where will my contract be deployed at?
Factory of Bob’s AA contract
getAddress(owner,salt)
0x1234beef
How to deploy your AA contract in ERC-4337?
Entrypoint
Bob
Please deploy my AA contract and execute my UserOp
deploy
UserOp {
…
sender: 0x1234beef
initcode: …
…
}
User’s AA contract
Factory of Bob’s AA contract
deploy
How to deploy your AA contract in ERC-4337?
Thank you
Apr 24 2023 | POPOP Taipei
Equal access to the Tokenized World