Replace the Sample Uniswap V3 Factory ABI with Another Contract's ABI
Replace the Uniswap V3 Factory ABI with another contract’s ABI in the Sim IDX sample app
This guide shows you how to swap out the Uniswap V3 Factory ABI bundled with the sample Sim IDX app and replace it with the ABI of any contract you would like to index. The sample app is what gets created by default when you run sim init
without any additional templates. The workflow mirrors the process you will follow in a real project: locate the ABI, register it with the CLI, extend your listener, and validate the new triggers against historical data.
1. Remove the Uniswap V3 Factory ABI from the project
Inside the sample repository you will find a file at abis/UniswapV3Factory.json
. Because you are replacing this ABI entirely, delete the file (or move it out of abis/
). Leaving it in place would cause the CLI to generate bindings for both Factory and USDC, which is not what you want for this walkthrough.
Running sim abi codegen
removes the now-missing Factory bindings from listeners/lib/sim-idx-generated/
.
2. Locate the ABI for your target contract
Start by obtaining the ABI for the contract you want to observe. The most common approach is to open the contract page on a blockchain explorer such as Etherscan, Basescan or Polygonscan and click the Contract tab. From there select Contract ABI and copy the full JSON blob to your clipboard.
For the purposes of this guide we’ll hook into the Ethereum USDC contract.
3. Add the new ABI JSON file
Create a fresh file under abis/
and paste the JSON you copied earlier. The filename should match the contract you are tracking, e.g. abis/USDC.json
.
You can just as easily create the file through your editor’s GUI. Both approaches work the same.
4. Generate Solidity bindings with sim abi add
Run the command below in the root of your project to register the ABI and generate strongly-typed Solidity bindings. The CLI parses the JSON, creates the corresponding structs, abstract contracts and helper functions, and writes them into listeners/lib/sim-idx-generated/
.
After the command completes you will see the updated files in listeners/lib/sim-idx-generated/
. The generated Solidity bindings expose multiple abstract contracts that fire whenever a specific USDC function is called or event is emitted on-chain. You will extend one of these contracts in the next step.
5. Update the listener contract to inherit the new functionality
Open listeners/src/Main.sol
and update the Listener
contract so that it inherits from the abstract contracts generated for your ABI. For example, to react to the Transfer
event of USDC the inheritance line might look like this:
Add or modify event definitions to capture the on-chain data you want persisted and implement each handler function required by the abstract contract. The Sim IDX framework will create the associated database tables automatically on deployment.
6. Register triggers for the new contract
In the Triggers
contract within the same Main.sol
file, replace the existing addTrigger
call so that it points to the USDC contract address on Ethereum and references the helper selector exposed by the listener:
Want to listen on multiple networks (e.g. Base)? Simply add additional addTrigger
calls with the appropriate chainId
and contract address. You can find the list of supported chains at sim.dune.com/chains.
7. Evaluate the listener against historical blocks
Before deploying, replay historical chain data to confirm that the new triggers activate and that the listener emits the expected events. sim listeners evaluate
compiles your listener, fetches on-chain transactions for the specified block range and prints a structured summary of events and errors.
Replace the placeholders with blocks that are known to interact with USDC. You can usually find them on the same explorer page where you copied the ABI. If the summary shows your custom events in events
and errors
is empty, the evaluation succeeded.
8. Update the listener tests
The default tests in listeners/test/Main.t.sol
assert Uniswap V3 Factory behaviour. Because the listener now emits USDCTransfer
events instead, the tests must be updated or sim test
will fail and block deployment.
Replace the contents of listeners/test/Main.t.sol
with:
Run sim test
to confirm all tests pass.
9. Rebuild and update the API endpoint
Next, rebuild the project so that Drizzle schemas are regenerated from the new events:
sim build
places the generated schema for your listener under apis/src/db/schema/Listener.ts
. The existing apis/src/index.ts
still imports poolCreated
(an event from the old sample) which no longer exists.
Update apis/src/index.ts
so that it queries the new usdcTransfer
table generated from your USDCTransfer
event:
After saving, run sim dev
to verify the API serves data from the updated table.
Next steps
With your listener, tests and API all pointing at USDC data, you’re ready to deploy the application to Sim’s managed infrastructure.