We can create a smart contract account using ERC-4337 right, now using that account we can interact with other smart contracts and it can hold assets, but my query is how can a smart contract account sign a transaction? and if the answer is an Externally owned account is used to sign the transaction then what is the sense of account abstraction if we still need to use an Externally owned account
2 Answers
That is the whole point of having smart accounts, to abstract away the need of signing a tx that needs the gas fees in native token.
Smart Accounts just need to send the user Operations, and the tx will be signed by bundler. So that, a user doesn't need to have ETH to do a transaction on Ethereum, instead they can pay in USDC or whatever currency the paymaster supports.
About the owner part:
When a simple account is created it's address is generated from the owner's address and it is also initialized with the owners address. Owner is a public variable that you can check anytime to see who's the owner of a smart account.
And there is a function to check whether or not the userOp is signed by the owner.
reference implementation for better understanding - reference repo
About senidng the user Operations
We hae multiple services for this purpose. like Biconomy, base, Safe Pimlico, Stackup, blocknative etc.
The easiest one was stack up for me here is the code snippet for sending the user Op.
The picture itself is not very clear about the steps to be taken. Here is the full script - StackupScript
I have written this script with the help of stackUp docs
You can write your script or run mine to see everything in action.
-
Thank you for your answer, I have one more query that how owner will be decided if there is no eoa means how will I verify that I am the owner of the smart account and not anyone else. Commented Dec 21, 2023 at 4:28
-
-
Thank you , then it means that having an eoa is necessary right? whose address we will be setting as owner and in that _validateSignature function it is checking for owner signature which I think is not possible without eoa. Commented Dec 21, 2023 at 5:02
-
and in your mentioned code reference how will the userOps will be initiated and send to bundlers Commented Dec 21, 2023 at 6:20
-
Yes EOA is needed for signing the userOp. About sending the userOp, I'll share a reference script in a few hours, busy rn. Commented Dec 21, 2023 at 9:22
You can use an EOA to create a signature under the hood but not expose the user to the need of holding the private keys. You will have to come up with a solution to manage private keys though. A good alternative for that is services like web3auth and magic, which enable users to log with email/social. An eoa will be created to each social used to login and you can use this eoa as an owner address to create a new smart account. If you use deterministic addresses via create2 methods you dont need to store any mapping between eoa -> smart accounts, you just need to use the same inputs and the return address will always be the same.
The point of aa is to create more flexible accounts with added functionalities like custom internal validation, verification hooks and so on. ERC-4337 is a scheme to enable this flexibility w/o making protocol level changes, using alternative mempools and metatransactions. Because of this, we still rely on eoa's to get the job done.