Developers
Most dApps can integrate with Compose Network without deploying new contracts. You can use existing contracts on each chain and leverage our bridge for asset transfers when needed.
Integration Flow
1. Ensure rollups are Compose Network Enabled
Verify that the chosen rollups support Compose Network. If not, the chain can be integrated with Compose.
Required components on each chain:
- Shared Publisher
- MailBox contracts
- Compose Bridge for asset transfers
2. Prepare contract calls and function data
You'll create cross-chain transactions by calling existing contracts on each chain. Here's a DEX example where a user has funds on Chain A but wants to swap on Chain B:
Example: Cross-Chain DEX Swap
User has ETH on Chain A, wants to swap for DAI on Chain B, and receive DAI back on Chain A.
Step 2A: Identify required contract calls
-
Chain A: Bridge ETH to Chain B with swap instruction
- Contract: Compose Bridge
- Function:
transferToChain(uint256 destinationChain, uint256 amount) - Note: Bridge handles mailbox write calls internally for cross-chain communication
-
Chain B: Execute swap using existing DEX
- Contract: Uniswap/SushiSwap/etc.
- Function:
swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline)
-
Chain B: Bridge DAI back to Chain A
- Contract: Compose Bridge
- Function:
transferToChain(uint256 destinationChain, uint256 amount) - Note: Bridge handles mailbox read/write calls internally for cross-chain communication
Step 2B: Prepare function data
For each contract call, you'll need to:
- Get the contract ABI
- Encode the function parameters
- Prepare the transaction data for signing
This function data will be used in Step 3 with ZeroDev to create the cross-chain transaction flow.
3. Execute cross-chain transactions
Once you've prepared your contract calls and function data, you can execute them using one of two approaches:
Option A: Use ZeroDev for Account Abstraction (Recommended)
ZeroDev provides Account Abstraction capabilities that enable batching transactions across multiple chains and signing them all together in one action. This approach is ideal for most dApps as it provides a seamless user experience.
Benefits:
- Batch multiple cross-chain transactions in a single signature
- Gas sponsorship capabilities
- Enhanced user experience with smart contract wallets
Implementation: See our Getting Started page for a complete code walkthrough.
Option B: Custom Contract Integration
For dApps requiring custom cross-chain logic, you can integrate Mailbox contracts directly into your smart contracts.
Benefits:
- Full control over cross-chain message handling
- Custom logic for complex cross-chain interactions
- Direct integration with existing contract architecture
Implementation: See our Custom Contract Development Tutorial for detailed examples.