Skip to content

pinax-network/subgraph-contract-creation

Repository files navigation

Subgraph: Contract Creation

Tracks smart contract creation events.

Build

Docker

docker build -t subgraph-contract-creation
docker run -it subgraph-contract-creation

Local

Important

Requires substreams, buf and graph CLIs installed as well as Rust with wasm32-unknown-unknown target.

make [all]

Contract creation substream

make spkg-build

Contract creation block index

make block-index

Subgraphs

make subgraph-build-[mainnet|...|all]

Data Includes

  • Contract Address
  • Creator Address
  • Creator Factory
  • Creator Transaction Hash
  • Contract Code
  • Contract Init bytecode

Subgraphs

Chain Subgraph ID
Ethereum EEWpgBNwW9TzJeHppqyGfRxeK6UuXErg3VVn6EoWjsuc
Arbitrum One 6w6xFpTo9HHKYYyL7d4HNDy28bG2fMNBiZLcwymoKwAh
BNB 7H7M2G2XSLBy7rzWcysC8DpCkEqJQNxMjUKFpgSgMCLc

GraphQL

{
  contract_creation(
    orderBy: block_number
    orderDirection: desc
  ) {
    block_number
    block_time
    block_date
    contract_address
    creator_address
    creator_factory
    creator_tx
    code
  }
}

Graph

graph TD;
  map_contract_creation[map: map_contract_creation];
  sf.substreams.v1.Clock[source: sf.substreams.v1.Clock] --> map_contract_creation;
  block_index:map_block_index --> map_contract_creation;
  db_out[map: db_out];
  map_contract_creation --> db_out;
  graph_out[map: graph_out];
  map_contract_creation --> graph_out;
  block_index:map_block_index[map: block_index:map_block_index];
  sf.ethereum.type.v2.Block[source: sf.ethereum.type.v2.Block] --> block_index:map_block_index;
Loading

Modules

Name: map_contract_creation
Initial block: 0
Kind: map
Input: source: sf.substreams.v1.Clock
Input: map: block_index:map_block_index
Output Type: proto:contract_creation.v1.Events
Hash: 18bfc7f7ae9c17af025cdf6a64e7808c4d9afa43

Name: db_out
Initial block: 0
Kind: map
Input: map: map_contract_creation
Output Type: proto:sf.substreams.sink.database.v1.DatabaseChanges
Hash: d8b19b08696ddb1c9d506f6bf87183646f18a743

Name: graph_out
Initial block: 0
Kind: map
Input: map: map_contract_creation
Output Type: proto:sf.substreams.sink.entity.v1.EntityChanges
Hash: e8a9a97db397c4c9803c65e35152bd7e796426a6

Name: block_index:map_block_index
Initial block: 0
Kind: map
Input: source: sf.ethereum.type.v2.Block
Output Type: proto:sf.ethereum.type.v2.Block
Hash: b0d44421a2658fe913898d3d612149adb2f41ef3

Subgraph deployment

graph indexer rules prepare --network arbitrum-one <Qm>
graph indexer allocations create <Qm> arbitrum-one 100