/erc4337-indexer

Simple multi-chain ERC-4337 indexer built using ponder

Primary LanguageTypeScript

ERC-4337 Indexer

Simple indexer for ERC-4337 accounts, built using ponder.

Installation

  1. Install dependencies
pnpm install
  1. Create a .env file, copy the contents of .env.example into it, and fill in the values.

Usage

pnpm dev

Networks

Adding a network

To add a network, add a new entry to the networks object in ponder.config.ts and add the network name to the network object inside the contracts object below. You will also need to define an RPC url in the .env file.

Removing a network

To remove a network, remove the entry from the networks object in ponder.config.ts and remove the network name from the network object inside the contracts object below.

Querying

While the indexer is running, you can query the data using the GraphQL playground at http://localhost:42069/. Some example queries are:

Get all deployed accounts:

{
  accountDeployeds {
    id
    sender
    factory
    paymaster
    chainId
    blockNumber
    blockHash
    timestamp
    transactionHash
    bundler
  }
}

Get all deployed accounts for a specific factory:

{
  accountDeployeds(
    where: { factory: "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3" }
  ) {
    id
    factory
    paymaster
    sender
    chainId
    blockNumber
    blockHash
    timestamp
    transactionHash
    bundler
  }
}

Get all UserOperations:

{
  userOperationEvents {
    actualGasCost
    actualGasUsed
    id
    nonce
    paymaster
    sender
    success
    chainId
    blockNumber
    blockHash
    timestamp
    transactionHash
    bundler
  }
}

Get all UserOperations for a specific account:

{
  userOperationEvents(
    where: {
      sender: "0x0f16e038614fd00cf13bb64f9e4e3a95af1ef2aa"
      chainId: 137
    }
  ) {
    actualGasCost
    actualGasUsed
    id
    nonce
    paymaster
    sender
    success
    chainId
    blockNumber
    blockHash
    timestamp
    transactionHash
    bundler
  }
}

Get all UserOperations for a specific account on a specific chain:

{
  userOperationEvents(
    where: { sender: "0x0f16e038614fd00cf13bb64f9e4e3a95af1ef2aa" }
  ) {
    actualGasCost
    actualGasUsed
    id
    nonce
    paymaster
    sender
    success
    chainId
    blockNumber
    blockHash
    timestamp
    transactionHash
    bundler
  }
}