Requirements for OATS Integration
To integrate your tokens with OATS, follow these steps.
1. Get the Gateway Addresses
First, you'll need the deployed address of the Analog GMP Gateway contract for each blockchain you plan to support. You can find these addresses in the Gateway Addresses & Network IDs page.
2. Choose Your Token Model
Decide how your token will move between chains. You have two options:
- Burn/Mint Model: This model burns tokens on the source chain and mints an equivalent amount on the destination chain.
- Lock/Unlock Model: This model locks tokens in a contract on the source chain and unlocks a corresponding amount of pre-existing tokens on the destination chain.
3. Implement the Smart Contract
For a Burn/Mint Model:
Your token contract must:
- Inherit Interfaces: Inherit
ISender(orISenderCaller) andIGmpReceiver. - Implement Functions: Add the
cost(),send()(orsendAndCall()), andonGmpReceived()functions. - Set Access Control: Ensure only authorized accounts can mint or burn tokens. For example, use
Ownableto manage network settings and restrictonGmpReceived()calls to the GMP Gateway. - Check Token Caps: If you're using
ERC20Capped, make sure the cap is high enough to handle cross-chain minting.
See Build Your First Omni-Chain dApp for more details.
For a Lock/Unlock Model:
You'll need a separate Bridge contract that:
- Inherits Interfaces: Implements
ISender(orISenderCaller) andIGmpReceiver. - Manages Tokens: Handles the locking and unlocking of the underlying ERC20 token. The original token contract doesn't need any changes.
See Build Your First Omni-Chain dApp for more details.
4. Configure Your Network
Your contract needs a way to map each networkId to the correct token or bridge contract address on other chains. You can manage this with a mapping that the contract owner can update.
5. Set Gas Limits
You must specify a GAS_LIMIT for the onGmpReceived function on the destination chain. While a starting value of 100,000 is suggested in the examples, you should test and adjust this based on your contract's specific needs and complexity.