Skip to main content
Compose allows you to interact with smart contracts with type safety and flexible wallet options. See wallets for details on the different types of wallets.

Code generation

To interact with smart contracts with full type safety, place your ABI JSON files in the src/contracts/ folder. Compose automatically generates TypeScript classes when you run compose start or compose deploy. You can also manually trigger code generation:
The generated file is written to .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.
If you deploy your contract with compose deployContract, the CLI writes its ABI to src/contracts/ for you, so you can run compose codegen immediately afterward.

Generated classes

For each ABI file (e.g., src/contracts/BitcoinOracleContract.json), Compose generates a typed class that you can access via evm.contracts:
Contract methods are called directly on the instance without .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 static decodeEventLog() method for decoding onchain events with full type safety. This is commonly used in tasks triggered by onchain events:
You can also use 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:
See the wallets documentation for the full writeContract, readContract, and sendTransaction signatures, gas handling, confirmations, and reorg protection options.