Code generation
To interact with smart contracts with full type safety, place your ABI JSON files in thesrc/contracts/ folder. Compose automatically generates TypeScript classes when you run compose start or compose deploy.
You can also manually trigger code generation:
.compose/generated/index.js. On compose deploy, the CLI bundles this file alongside your tasks so the same typed classes are available in the cloud.
Generated classes
For each ABI file (e.g.,src/contracts/BitcoinOracleContract.json), Compose generates a typed class that you can access via evm.contracts:
.write or .read suffixes. View/pure functions return their decoded value directly, while state-changing functions return { hash, receipt, userOpHash? } (the userOpHash is present only when gas sponsoring routes the transaction through a bundler).
Decoding event logs
Each generated contract class includes a staticdecodeEventLog() method for decoding onchain events with full type safety. This is commonly used in tasks triggered by onchain events:
decodeEventLog with a generic type parameter for a single known event type:
Direct wallet methods
You can also interact with contracts directly through wallet methods without generated classes. This is useful for one-off calls or contracts you don’t want to check an ABI into the repo for:writeContract, readContract, and sendTransaction signatures, gas handling, confirmations, and reorg protection options.