graphite.toml Reference

graphite.toml is the single config file for a Graphite project. graphite codegen, graphite manifest, graphite build, and graphite deploy all read from it.

Top-Level Fields

output_dir = "src/generated"   # where codegen writes Rust source
schema     = "schema.graphql"  # path to your GraphQL schema
network    = "mainnet"         # network name
FieldTypeRequiredDescription
output_dirstringyesDirectory for generated Rust source.
schemastringyesPath to schema.graphql.
networkstringyesNetwork name (e.g. mainnet, arbitrum-one, matic).

[[contracts]]

One [[contracts]] section per indexed contract.

[[contracts]]
name        = "ERC20"
abi         = "abis/ERC20.json"
address     = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
start_block = 6082465
receipt     = false               # optional, default false
FieldTypeRequiredDescription
namestringyesContract name. Used to prefix generated types (e.g. ERC20TransferEvent).
abistringyesPath to the ABI JSON file.
addressstringyesContract address to index.
start_blockintegeryesBlock number to start indexing from.
receiptboolnoExpose TransactionReceipt in ctx.receipt. Default false.

[[contracts.event_handlers]]

Declare which ABI events map to which handler functions. These are auto-generated by codegen but can be customised.

[[contracts.event_handlers]]
event   = "Transfer(address,address,uint256)"
handler = "handle_transfer"

[[contracts.call_handlers]]

[[contracts.call_handlers]]
function = "transfer(address,uint256)"
handler  = "handle_transfer_call"
FieldDescription
functionFull function signature, e.g. transfer(address,uint256).
handlerRust function name (without the WASM extern "C" wrapper).

[[contracts.block_handlers]]

# Every block
[[contracts.block_handlers]]
handler = "handle_block"

# Every N blocks
[[contracts.block_handlers]]
handler = "handle_block_polled"
filter  = { kind = "polling", every = 10 }
FieldDescription
handlerRust function name.
filterOptional. { kind = "polling", every = N } to fire every N blocks.

[[templates]]

Dynamic data source templates. Used with the factory pattern. See Dynamic Data Sources.

# Contract template
[[templates]]
name = "Pair"
abi  = "abis/Pair.json"

# IPFS file template
[[templates]]
name    = "NFTMetadata"
kind    = "file/ipfs"
handler = "handle_nft_metadata"
FieldTypeRequiredDescription
namestringyesTemplate name. Passed to data_source::create_contract.
abistringfor contract templatesABI path.
kindstringfor file templates"file/ipfs".
handlerstringfor file templatesHandler function name.

Complete Example

output_dir = "src/generated"
schema     = "schema.graphql"
network    = "arbitrum-one"

[[contracts]]
name        = "Factory"
abi         = "abis/Factory.json"
address     = "0x1234...5678"
start_block = 175000000

[[contracts.event_handlers]]
event   = "PairCreated(address,address,address,uint256)"
handler = "handle_pair_created"

[[templates]]
name = "Pair"
abi  = "abis/Pair.json"

[[templates.event_handlers]]
event   = "Swap(address,uint256,uint256,uint256,uint256,address)"
handler = "handle_swap"