Ethereum and EVM networks

                              @
                             @@@
                           .@@@@@@
                          @@@@@@@@@
                         @@@@@@@@@@@.
                       .@@@@@@@@@@@@@@
                      @@@@@@@@@@@@@@@@@
                     @@@@@@@@@@@@@@@@@@@.
                    @@@@@@@@@@@@@@@@@@@@@@
                  @@@@@@@@@@@@((@@@@@@@@@@@
                 @@@@@@@@@@((((((((@@@@@@@@@.
                @@@@@@@@((((((((((((((@@@@@@@@
              @@@@@@(((((((((((((((((((((@@@@@@
             @@@((((((((((((((((((((((((((((@@@@
            (((((((((((((((((((((((((((((((((((((,
               (((((((((((((((((((((((((((((((^
                  *((((((((((((((((((((((((
                      (((((((((((((((((
              @@@.        (((((((((*       .@@^
                @@@@.        *((       .@@@@@
                 @@@@@@@           ..@@@@@@
                   @@@@@@@@@.   .@@@@@@@@@
                    ^@@@@@@@@@@@@@@@@@@@
                      @@@@@@@@@@@@@@@@@
                       @@@@@@@@@@@@@@
                         @@@@@@@@@@^
                           @@@@@@@
                            @@@@^
                              @

Apibara provides preview streams for Ethereum. Streaming Ethereum data is still in preview and is subject to breaking changes as we finalize the DNA v2 protocol based on early users feedback. No authentication is required.

Ethereum Sepolia testnet (partial)

sepolia.ethereum.a5a.ch

Testing DNA v2

At the moment, we don't provide precompiled binaries for DNA v2. If you'd like to test DNA v2 and its EVM integration, you must compile binaries from the source.

  1. Clone the repository and switch to the dna-v2 branch.
  2. Install a Rust toolchain, either using nix (nix develop) or with rustup.
  3. Compile the binary you want to use. For example to test the MongoDB integration: cargo build --release -p apibara-sink-mongo.

Getting started with EVM data

Example indexer

The following indexer listens for all ERC-20 Transfer events on Sepolia and prints them to stdout.

Change the sinkType to:

indexer.js
import {
  decodeEventLog,
  encodeEventTopics,
  parseAbi,
} from "https://esm.sh/viem";

const abi = parseAbi([
  "event Transfer(address indexed from, address indexed to, uint256 value)",
]);

export const config = {
  streamUrl: "https://sepolia.ethereum.a5a.ch",
  startingBlock: 5_000_000,
  network: "evm",
  filter: {
    header: {},
    logs: [
      {
        strict: true,
        topics: encodeEventTopics({
          abi,
          eventName: "Transfer",
          args: [null, null],
        }),
      },
    ],
  },
  sinkType: "console",
  sinkOptions: {},
};

export default function transform({ header, logs }) {
  return (logs ?? []).flatMap(({ address, topics, data, transactionHash }) => {
    const decoded = decodeEventLog({ abi, topics, data });
    return {
      tokenAddress: address,
      eventName: decoded.eventName,
      from: decoded.args.from,
      to: decoded.args.to,
      value: decoded.args.value.toString(10),

      transactionHash,
      blockNumber: header.number.toString(10),
      blockHash: header.hash,
      blockTimestamp: header.timestamp,
    };
  });
}

Run with apibara-sink-console run indexer.js.

Last modified
Edit on GitHub
Apibara

Apibara is the fastest platform to build production-grade indexers that connect onchain data to web2 services.

© 2024 GNC Labs Limited. All rights reserved.