Understand the folder structure of a Sim IDX app.
Running sim init
creates a new Sim IDX app with the folder structure shown above.
The following sections explain each folder’s purpose and contents in detail.
The sim.toml
file is your app’s main configuration file. It contains your app’s name
and a [listeners]
table for configuring code generation.
The name
field is used internally by Sim IDX for resource naming and deployment.
The codegen_naming_convention
field in the [listeners]
table controls how function and type names are generated from your ABIs. This manages potential name conflicts when you index multiple contracts. It supports two values:
"plain"
(Default): Generates clean names without any prefixes (e.g., onSwapFunction
). This is the most common setting, especially when you split logic for different ABIs into separate listener contracts."abi_prefix"
: Prefixes generated names with the ABI’s name (e.g., ABI1$onSwapFunction
). Use this option to prevent compilation errors when a single listener contract must handle functions with the same name from two different ABIs.The abis/
folder contains JSON ABI files of smart contracts you want to index. The sample app includes abis/UniswapV3Factory.json
for the Uniswap V3 Factory contract.
When you add a new ABI with the sim abi add
CLI command, it automatically generates Solidity bindings in listeners/lib/sim-idx-generated/
.
The apis/
folder is a complete Node.js project that provides TypeScript API endpoints running on the Cloudflare Workers Edge runtime.
The src/index.ts
file defines your HTTP routes, while src/db/schema/Listener.ts
is produced by sim build
and exposes your listener-generated tables through Drizzle ORM for type-safe queries.
The listeners/
folder is a Foundry project that contains everything related to on-chain indexing. The Triggers
contract must be defined in src/Main.sol
, but handler logic can be implemented in one or more listener contracts, which can have any name and be defined across multiple .sol
files in the src/
directory. Unit tests live under the test/
directory. Foundry will discover any file ending in .t.sol
, so you can add as many unit-test files as you need (e.g., Main.t.sol
, SwapHandlers.t.sol
, etc.).
During sim build
, the framework inserts core helpers into lib/sim-idx-sol/
and writes ABI-specific bindings into lib/sim-idx-generated/
. These generated files should not be edited directly.
Here’s how these folders work together:
abis/YourContract.json
sim abi add
creates Solidity bindingslisteners/src/
listeners/test/
(e.g., any *.t.sol
files)apis/src/
to query your datamain
) and follow the steps in the deployment guide to promote them to a live environment