Skip to main content

ARecoverableAccount

Overview​

License: MIT​

abstract contract ARecoverableAccount is IAccount, Initializable, AAccountRecovery, ERC7821

EIP-7702/ERC-4337 Recoverable Account module

A basic EIP-7702/ERC-4337 account implementation with ERC-7821 batching execution, ERC-4337 sponsored transactions, and ERC-7947 recoverable trusted executor.

Structs info​

RecoverableAccountStorage​

struct RecoverableAccountStorage {
address entryPoint;
address trustedExecutor;
}

Events info​

TrustedExecutorUpdated​

event TrustedExecutorUpdated(address indexed oldTrustedExecutor, address indexed newTrustedExecutor)

Errors info​

NotSelfCalled​

error NotSelfCalled()

InvalidExecutor​

error InvalidExecutor(address executor)

Constants info​

SIG_VALIDATION_FAILED (0x8f41ec5a)​

uint256 constant SIG_VALIDATION_FAILED = 1

SIG_VALIDATION_SUCCESS (0x861af77c)​

uint256 constant SIG_VALIDATION_SUCCESS = 0

Modifiers info​

onlySelfCalled​

modifier onlySelfCalled()

Functions info​

addRecoveryProvider (0x180e8d5c)​

function addRecoveryProvider(
address provider_,
bytes memory recoveryData_
) external payable virtual override onlySelfCalled

A function to add a new recovery provider. SHOULD be access controlled.

Parameters:

NameTypeDescription
provider_addressthe address of a recovery provider (ZKP verifier) to add.
recoveryData_bytescustom data (commitment) for the recovery provider.

removeRecoveryProvider (0xefe4256c)​

function removeRecoveryProvider(
address provider_
) external payable virtual override onlySelfCalled

A function to remove an existing recovery provider. SHOULD be access controlled.

Parameters:

NameTypeDescription
provider_addressthe address of a previously added recovery provider to remove.

recoverAccess (0x15494a7d)​

function recoverAccess(
bytes memory subject_,
address provider_,
bytes memory proof_
) external virtual override returns (bool)

A non-view function to recover access of a smart account.

Parameters:

NameTypeDescription
subject_bytesthe recovery subject (encoded owner address, access control role, etc).
provider_addressthe address of a recovery provider.
proof_bytesan encoded proof of recovery (ZKP/ZKAI, signature, etc).

Return values:

NameTypeDescription
[0]booltrue if recovery is successful, false (or revert) otherwise.

validateUserOp (0x19822f7c)​

function validateUserOp(
IAccount.PackedUserOperation calldata userOp_,
bytes32 userOpHash_,
uint256 missingAccountFunds_
) external virtual returns (uint256 validationData_)

A function to validate a PackedUserOperation for the account.

This function is called from the EntryPoint while executing the user operation. Must be implemented by accounts to verify signatures and pay required funds.

Parameters:

NameTypeDescription
userOp_struct IAccount.PackedUserOperationThe user operation being validated.
userOpHash_bytes32The user operation hash used for signature validation.
missingAccountFunds_uint256Amount that the account must fund to the EntryPoint.

Return values:

NameTypeDescription
validationData_uint256The result of the signature validation.

trustedExecutor (0x39584b19)​

function trustedExecutor() public view virtual returns (address)

A function to retrieve the current trusted executor.

Return values:

NameTypeDescription
[0]addressThe address of the current trusted executor.

entryPoint (0xb0d691fe)​

function entryPoint() public view virtual returns (address)

A function to retrieve the address of the EntryPoint this account is bound to.

Return values:

NameTypeDescription
[0]addressThe EntryPoint contract address.