Skip to content

mulfdev/evm-events

Repository files navigation

Open in Gitpod

Squid ABI template

An experimental template is used to generate a squid that indexes EVM logs and transactions of choice from a contract address. Supports automatic ABI lookups for public contracts using the Etherscan API

Usage

  1. Install the Squid CLI:
npm i -g @subsquid/cli
  1. Init the template and install the dependencies
sqd init my-abi-squid --template https://github.com/subsquid/squid-abi-template
cd my-abi-squid
npm i
  1. Run sqd generate with the appropriate flags.
Usage: sqd generate [options]

Options:
  --address <contract>      contract address
  --archive <url>           archive endpoint 
  --abi <path>              (Optional) path or URL to the abi file. If omitted, the Etherscan API is used.
  -e, --event <name...>     one or multiple events to be indexed. '*' will index all events
  -f, --function <name...>. one or multiple contract functions to be indexed. '*' will index all functions
  --from <block>            start indexing from the given block. 
  --etherscan-api <url>     (Optional) an Etherscan-compatible API to fetch contract ABI by a known address. Default: https://api.etherscan.io/
  1. Build and run the squid
sqd build
sqd up
sqd migration:generate
sqd process

The indexing will start.

In a separate window, start the GraphQL API server at localhost:4350/graphql:

sqd serve
  1. Inspect schema.graphql, src/processor.ts and start hacking!

For more details on how to build and deploy a squid, see the docs.

Example

Generate

npx squid-gen-abi \
--address 0x2E645469f354BB4F5c8a05B3b30A929361cf77eC \
--archive https://eth.archive.subsquid.io \
--event NewGravatar \
--event UpdatedGravatar \
--function createGravatar \
--from 6000000

Explore

query MyQuery {
  events(orderBy: block_timestamp_ASC) {
    id
    name
    block {
      number
      timestamp
    }
    ... on NewGravatarEvent {
      id0
      imageUrl
      owner
    }
    ... on UpdatedGravatarEvent {
      id0
      imageUrl
      owner
    }
  }
}

Example

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published