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 atabis/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.
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 trigger on the Ethereum USDC contract.
3. Add the new ABI JSON file
Create a fresh file underabis/
and paste the JSON you copied earlier. The filename should match the contract you are tracking, e.g. abis/USDC.json
.
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/
.
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 onchain. You will extend one of these contracts in the next step.
5. Update the listener contract to inherit the new functionality
Create a new file atlisteners/src/USDCListener.sol
.
Next, create a new 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:
USDCListener.sol
6. Register triggers for the new contract
In theMain.sol
file, you now need to import your new USDCListener
and update the Triggers
contract to use it.
In the Triggers
contract, 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:
Main.sol
addTrigger
calls with the appropriate chain name from the Chains
enum (for example, Chains.Base
) 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 onchain transactions for the specified block range and prints a structured summary of events and errors.
events
and errors
is empty, the evaluation succeeded.
To learn more about the
sim listeners evaluate
command and its options, visit the CLI reference page.8. 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 Drizzle schema for your listener under apis/src/db/schema/Listener.ts
. The existing apis/src/index.ts
still imports poolCreated
(an event from the previous Uniswap V3 ABI included in the sample) which no longer exists.
Update apis/src/index.ts
so that it queries the new usdcTransfer
table generated from your USDCTransfer
event:
index.ts
sim build
once again to verify the API is building correctly with the new Drizzle schema.