Home

Awesome

Starknet indexer

This is an indexing layer for Starknet written in Golang that operates on top of the Node API and stores data in a Postgres database.

It can be used in multiple ways and for various purposes:

What you can build with DipDup:

Features

Documentation

Check out the repository wiki to learn more about the indexer internals:

Also check out the cmd/rpc_tester folder with simple events indexers for Starknet.ID and Loot Survivor.

Public instances

Public deployments with reasonable rate limits are available for testing and prototyping:

Notes

Example queries

Get token balances

Querying token balances for a given account.

query GetTokenBalances {
  token_balance(
    where: {owner: {hash: {_eq: "\\x06ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678"}}}
  ) {
    owner_id
    balance
    token {
      metadata
      id
      type
      contract {
        hash
      }
    }
  }
}

Few things to note:

Get L1<>L2 messages

Querying messages and l1_handler operations for the StarkGate contract.

query GetStarkGateMessages {
  message(
    where: {contract: {hash: {_eq: "\\x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82"}}}
    order_by: {id: desc}
    limit: 5
  ) {
    payload
    time
    to {
      hash
    }
  }
  l1_handler(
    where: {contract: {hash: {_eq: "\\x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82"}}}
    order_by: {id: desc}
    limit: 5
  ) {
    parsed_calldata
    time
    status
    entrypoint
  }
}

Notes on the response:

Get event logs

Querying Starknet.ID events.

query GetStarknetIDs {
  event(
    where: {contract: {hash: {_eq: "\\x06ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678"}}, name: {_eq: "domain_to_addr_update"}}
    limit: 20
    order_by: {id: desc}
  ) {
    parsed_data
    time
  }
}

Get token transfers

query GetSithSwapTransfers {
  transfer(
    where: {to: {class: {hash: {_eq: "\\x07eb597ad7d9ba28ea1db162cdb99e265fe22bcb00e9b690e188c2203de9e005"}}}}
    limit: 50
    order_by: {id: desc}
  ) {
    amount
    from {
      hash
    }
    to {
      hash
    }
    token_id
    contract {
      hash
    }
    time
  }
}

Get internal transactions

Querying execution trace for a SithSwap swap.

query GetExecutionTrace {
  internal_tx(
    where: {hash: {_eq: "\\x07563ba09f924376edfdaf94b11941680867993d9caf271ae791ff4e89740177"}}
    order_by: {id: asc}
  ) {
    parsed_calldata
    parsed_result
    entrypoint
    caller {
      hash
    }
    call_type
    contract {
      hash
    }
  }
}

About

DipDup Vertical for Starknet is a federated API including the following services:

Project is supported by Starkware and Starknet Foundation via OnlyDust platform