MCPcopy
hub / github.com/eth-infinitism/account-abstraction

github.com/eth-infinitism/account-abstraction @v0.9.0 sqlite

repository ↗ · DeepWiki ↗ · release v0.9.0 ↗
150 symbols 563 edges 37 files 7 documented · 5%
README

Description

This repository contains the tools and resources for working with ERC-4337 Account Abstraction smart contracts. This includes the code for the singleton EntryPoint contract that is deployed by our team on most EVM-compatible networks.

Overview

Account abstraction allows users to interact with Ethereum using smart contract wallets instead of EOAs, without compromising decentralization, providing benefits like:

  • Social recovery
  • Batched transactions
  • Sponsored transactions (gas abstraction)
  • Signature abstraction
  • Advanced authorization logic

Repository Structure

Core Components

  • EntryPoint Contract (contracts/core/EntryPoint.sol): The central contract that processes UserOperations
  • BaseAccount (contracts/core/BaseAccount.sol): Base implementation for smart contract accounts
  • BasePaymaster (contracts/core/BasePaymaster.sol): Helper class for creating a paymaster
  • StakeManager (contracts/core/StakeManager.sol): Manages deposits and stakes for accounts and paymasters
  • NonceManager (contracts/core/NonceManager.sol): Handles nonce management for accounts
  • UserOperationLib (contracts/core/UserOperationLib.sol): Utilities for working with UserOperations
  • Helpers (contracts/core/Helpers.sol): Common constants and helper functions

Sample Implementations

  • SimpleAccount (contracts/accounts/SimpleAccount.sol): Basic implementation of an ERC-4337 account

  • Simple7702Account (contracts/accounts/Simple7702Account.sol): A minimal account to be used with EIP-7702 (for batching) and ERC-4337 (for gas sponsoring)

  • SimpleAccountFactory (contracts/accounts/SimpleAccountFactory.sol): A sample factory contract for SimpleAccount

Developer setup

Installation

Clone the repository:

git clone https://github.com/eth-infinitism/account-abstraction.git
cd account-abstraction
yarn install

Compilation:

yarn compile

Testing:

yarn test

Entrypoint Deployment

The EntryPoint contract is the central hub for processing UserOperations. It: - Validates UserOperations - Handles account creation (if needed) - Executes the requested operations - Manages gas payments and refunds

The EntryPoint is deployed by using

hardhat deploy --network {net}

EntryPoint v0.8 is always deployed at address 0x4337084d9e255ff0702461cf8895ce9e3b5ff108

This repository also includes a number of audited base classes and utilities that can simplify the development of AA related contracts.

Usage

For projects integrating the library

If you are building a project that uses account abstraction and want to integrate our contracts:

yarn add @account-abstraction/contracts

For Paymaster development

import "@account-abstraction/contracts/core/BasePaymaster.sol";

contract MyCustomPaymaster is BasePaymaster {
    /// implement your gas payment logic here
    function _validatePaymasterUserOp(
        PackedUserOperation calldata userOp,
        bytes32 userOpHash,
        uint256 maxCost
    ) internal virtual override returns (bytes memory context, uint256 validationData) {
        context = “”; // specify “context” if needed in postOp call. 
        validationData = _packValidationData(
            false,
            validUntil,
            validAfter
        );
    }
}

For Smart Contract Account development

import "@account-abstraction/contracts/core/BaseAccount.sol";

contract MyAccount is BaseAccount {

    /// implement your authentication logic here
    function _validateSignature(PackedUserOperation calldata userOp, bytes32 userOpHash)
    internal override virtual returns (uint256 validationData) {

        // UserOpHash can be generated using eth_signTypedData_v4
        if (owner != ECDSA.recover(userOpHash, userOp.signature))
            return SIG_VALIDATION_FAILED;
        return SIG_VALIDATION_SUCCESS;
    }
}

Resources

Extension points exported contracts — how you extend this code

UnsignedEIP7702Authorization (Interface)
(no doc)
test/eip7702helpers.ts
ValidationData (Interface)
(no doc)
test/testutils.ts
Eip7702Transaction (Interface)
(no doc)
test/GethExecutable.ts
FillUserOpOptions (Interface)
(no doc)
test/UserOp.ts
UserOperation (Interface)
(no doc)
test/UserOperation.ts
DebugLog (Interface)
(no doc)
test/debugTx.ts
QueueSendUserOp (Interface)
(no doc)
src/AASigner.ts
GasTestInfo (Interface)
(no doc)
gascalc/GasChecker.ts

Core symbols most depended-on inside this repo

fillSignAndPack
called by 75
test/UserOp.ts
deploy
called by 57
src/Create2Factory.ts
createAddress
called by 52
test/testutils.ts
packUserOp
called by 36
test/UserOp.ts
getAddress
called by 36
src/AASigner.ts
createAccountOwner
called by 33
test/testutils.ts
simulateValidation
called by 29
test/UserOp.ts
connect
called by 26
src/AASigner.ts

Shape

Function 84
Method 42
Class 12
Interface 12

Languages

TypeScript100%

Modules by API surface

test/testutils.ts31 symbols
src/AASigner.ts23 symbols
test/UserOp.ts22 symbols
gascalc/GasChecker.ts22 symbols
test/GethExecutable.ts10 symbols
test/eip7702helpers.ts8 symbols
src/Create2Factory.ts8 symbols
test/userOpHash.test.ts4 symbols
test/debugTx.ts4 symbols
test/entrypointsimulations.test.ts2 symbols
test/entrypoint.test.ts2 symbols
test/chaiHelper.ts2 symbols

Dependencies from manifests, versioned

@ethersproject/abi5.7.0 · 1×
@ethersproject/abstract-provider5.7.0 · 1×
@ethersproject/abstract-signer5.7.0 · 1×
@ethersproject/bytes5.7.0 · 1×
@ethersproject/properties5.7.0 · 1×
@ethersproject/providers5.7.2 · 1×
@nomiclabs/hardhat-ethers2.0.2 · 1×
@nomiclabs/hardhat-waffle2.0.1 · 1×
@openzeppelin/contracts5.1.0 · 1×
@typechain/ethers-v510.1.0 · 1×
@typechain/hardhat2.3.0 · 1×
@types/chai4.3.20 · 1×

For agents

$ claude mcp add account-abstraction \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact