Implementation
Last updated
Last updated
IAccount interface
It contains the following 5 methods:
IPaymaster interface
Like in EIP4337, our account abstraction protocol supports paymasters: accounts that can compensate for other accounts' transactions execution. Each paymaster should implement the IPaymaster It contains the following two methods:
Transaction process
Each transaction undergoes the following process:
Validation process
In the validation step, the account validates whether or not to accept the transaction and pays the transaction fees if accepted. If the validation fails, the account is not charged, and the transaction cannot be included in a block. The system verifies that the nonce of the transaction has not been used before, then calls the account's validateTransaction method. If it does not revert, the system proceeds to the next step. Next, the system verifies that the nonce of the transaction has been marked as used.
Then, the system calls the payForTransaction method of the account. If it does not revert, the system proceeds to the next step. Next, the system calls the prePaymaster method of the sender, and if it does not revert, the validateAndPayForPaymasterTransaction method of the paymaster is called. If it does not revert too, the system proceeds to the next step. The system checks that the bootloader has received sufficient ETH to the system contract. If so, the verification process is considered complete and can move on to the next step.
Execution process
The execution step is responsible for executing the transaction and sending refunds for any unused gas back to the user. If there is a revert at this stage, the transaction is still considered valid and will be included in the block. The system calls the executeTransaction method of the account. If the transaction involves a paymaster, the postOp method of the paymaster is called. This step is typically used to refund the sender the unused gas if the paymaster facilitated paying fees in ERC-20 tokens.
Fees
EIP4337 describes three types of gas limits: verificationGas, executionGas, and preVerificationGas, which define the gas limit for the different steps of transaction inclusion in a block. However, AChain only has a single field, gasLimit, which covers the fee for all three. When submitting a transaction, ensure that the gasLimit is sufficient to cover the verification process.