Bridge

Integrate With the Bridge

10min

Integrating Token Contracts With the Bridge

In the previous post we went through how the bridge operates.

This article explains what you need to do to integrate your token contracts with the bridge so that token owners can transfer them between Palm and Ethereum networks.



Original Contracts vs Synthetic Contracts

In the context of the Palm network's bridge, an original contract sits where tokens are primarily minted. A synthetic contract is deployed on the chain where tokens will be transferred via the bridge.

Deploying both original and synthetic contracts ensures that tokens can be transferred back and forth between the original and destination chains.

You might need to make some changes to your contracts for them to be bridge-compatible:

The below specifications applies to ERC-721 contracts. Tutorials for ERC-1155 or ERC-20 contracts will be provided in the future.



Original contract

  1. Add the Enumerable extension from Open Zeppelin libraries
    • Enumerability of all the token IDs in the contract
    • Support for all token IDs owned by each account

In addition to Enumerable, any custom implementation of ERC-721 is allowed: bulk minting, token ID auto-increment, etc.

Synthetic contract

  1. Add the Enumerable extension from Open Zeppelin libraries
  2. Create a custom mint() function.
  3. Grant Minting Permission to the Bridge
  4. Add a burn() function.
  5. Grant Burning Permission to the Bridge


Contract Example | Original and Synthetic Contracts



ERC-721 contract example



Testing your contracts

You can use the Palm Testnet bridge to live-test your contracts' integration with the bridge. All you need is to deploy them to Palm testnet and Goerli (Ethereum's main testnet).

For ERC-721 contracts, you will need to initialize it using the constructor, and grant the bridge's ERC-721 handler contract MINTER_ROLE. See the Bridge Component Addresses for relevant contract addresses.

Your original and synthetic can be exactly the same as in production.



How to Use the Bridge

Once you have prepared your contracts for the bridge, feel free to contact us on discord to validate your contracts compatibility. Testing will be done by our team on the testnet and set for production.

If everything looks OK, you will grant minter and/or burner roles to the bridge's ERC721 handler contract address, and then we will register the contracts with the bridge so that tokens can be transferred by owners.

We strongly recommend testing your contracts with the testnet bridge before setting them up with the mainnet bridge.