graphite.toml is the single config file for a Graphite project. graphite codegen, graphite manifest, graphite build, and graphite deploy all read from it.
output_dir = "src/generated" # where codegen writes Rust source
schema = "schema.graphql" # path to your GraphQL schema
network = "mainnet" # network name
Field Type Required Description
output_dirstring yes Directory for generated Rust source.
schemastring yes Path to schema.graphql.
networkstring yes Network name (e.g. mainnet, arbitrum-one, matic).
One [[contracts]] section per indexed contract.
[[contracts]]
name = "ERC20"
abi = "abis/ERC20.json"
address = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
start_block = 6082465
receipt = false # optional, default false
Field Type Required Description
namestring yes Contract name. Used to prefix generated types (e.g. ERC20TransferEvent).
abistring yes Path to the ABI JSON file.
addressstring yes Contract address to index.
start_blockinteger yes Block number to start indexing from.
receiptbool no Expose TransactionReceipt in ctx.receipt. Default false.
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]]
function = "transfer(address,uint256)"
handler = "handle_transfer_call"
Field Description
functionFull function signature, e.g. transfer(address,uint256).
handlerRust function name (without the WASM extern "C" wrapper).
# Every block
[[contracts.block_handlers]]
handler = "handle_block"
# Every N blocks
[[contracts.block_handlers]]
handler = "handle_block_polled"
filter = { kind = "polling", every = 10 }
Field Description
handlerRust function name.
filterOptional. { kind = "polling", every = N } to fire every N blocks.
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"
Field Type Required Description
namestring yes Template name. Passed to data_source::create_contract.
abistring for contract templates ABI path.
kindstring for file templates "file/ipfs".
handlerstring for file templates Handler function name.
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"