Bridge

15min

Overview

The Palm network enables efficient NFT minting & trading due to its:

  • speed ✅
  • cost-effectiveness ✅
  • sustainability ✅

Some users might decide to move their assets from the Palm network to Ethereum in order to reach specific marketplaces and they can transfer those token(s) using the Palm network bridge.

The Palm network bridge connects the Palm network with Ethereum. It allows transferring assets such as ERC-20, ERC-721 or ERC-1155 tokens back and forth between the Palm network and Ethereum.

As a developer you can support those end users by ensuring your smart contracts are compatible with the Palm network bridge.



How the Bridge Works

The bridge locks tokens that have already been minted on one side of the bridge and then minting an equivalent token on the other side, using what we call a “synthetic” version of the token contract:

Palm Token Bridge Flow

Document image


Palm Token Reverse Bridge Flow

Users can also send their tokens back to the original side. The bridge will burn the synthetic token and release the original token that will be transferred to the destination wallet address.

Document image



Bridge Fees

A fee is required to transfer assets from the Palm network to Ethereum. Part of this charge covers the cost of gas and the other part is used to purchase carbon offsets to make these operations carbon neutral. Moving assets back to Palm will top up the depositor’s account with a small amount of PALM tokens.



What Does an End-User See When They Use the Bridge?

The Palm network provides a user-friendly dApp to initiate the transfer and approve the transfer fees in DAI.



How the Bridge Operates

The Palm bridge is based on ChainSafe's ChainBridge, a communication protocol where events on the source chain are used to send messages routed to the destination chain where they will then be submitted as transactions. Permissioned and trusted relayers are used to send and verify the messages between the chains.

ChainBridge Concepts

Concept

Description

Relayers

Off-chain servers that listen for particular events on the source chain and submit signed proposals to the destination chain.

Bridge contracts

Delegate calls to the handler contracts for deposits, start a transaction on the source chain, and execute the proposals on the target chain.

Handler contracts

Palm’s handler contracts send mint/burn token transactions depending on the user input.

Target contracts

On Palm, target contracts are ERC-20, ERC-721 and ERC-1155 on each side of the bridge.

Deposit() function

A deposit is simply the initiation of a transfer of a piece of data, often representing instructions to lock a token in the bridge. In the reverse direction, the deposit is an instruction to burn a token.

Resource ID

Identifier for the transferring token’s smart contract. Resource ID is used to link the equivalent contracts on both sides of the bridge.

Chain ID

Identifier of the chain, for example, Palm network or Ethereum

Calldata

Payload contained by an event/proposal. The calldata represents a function to be executed on the targeted chain. On Palm, calldata represent the mint() functions.



Transfer flow

Overview of when End-user uses the bridge

Below is the workflow occurring when a user transfers an ERC-721 token from the Palm network to Ethereum:

  1. The user calls the deposit() function on Palm network’s bridge contract. The user must provide the:
    1. target chain - 01 for Ethereum network, 02 for Palm network)
    2. resource ID
    3. calldata, which represent a token transfer to be executed on Ethereum.
  2. The ERC-721 handler’s deposit() function is called, which verifies the data provided by the user.
  3. The bridge then locks the token on the ERC-721 contract.
  4. The Palm’s bridge contract then emits a deposit event containing the data that will be executed on Ethereum.
  5. On ChainBridge, this type of event is called a proposal.
  6. Once the bridge’s first relayer detects the event on Ethereum, it executes the proposal on Ethereum via the bridge.
  7. The proposal delegates an executeDeposit call to the ERC-721 handler contract.
  8. The ERC-721 handler’s executeDeposit function validates the parameters provided by the user and makes a call to the target ERC-721 contract to mint the token with the original ID.
  9. A custom mint function on the target contract is passed the token ID as part of the calldata to ensure this. The token is transferred to the recipient’s account on Ethereum.


Bridge Fee Calculation

The Palm network bridge automatically calculates and adjusts the fees based on average Ethereum gas prices. It updates every 3 hours, so the fees reflect the cost of gas incurred by the bridge.

The bridge is designed to be cost-neutral, and the Palm network does its best to set the price in a fair, stable, and predictable way, even when the underlying gas prices are changing.

Ethereum Gas Prices Over 1 Year
Ethereum Gas Prices Over 1 Year



Technical Aspects

When transferring to Ethereum, there are 2 transactions executed by the bridge on Mainnet.

  1. The first transaction confirms that the tokens on the Palm network side are definitely locked in the bridge (when moving NFTs) or are burned (when moving DAI or other ERC-20 tokens back to Ethereum).
  2. The second transaction will transfer the token to the recipient wallet address. Depending on the token type, the gas consumed by these transactions is usually just under 400,000 units total. The gas cost is calculated by multiplying gas usage by gas price:
400,000 × 100 gwei = 0.04 Ether

When gas is 50 gwei, consumption will be 0.02 Ether

Designed to be cost-neutral, the median gas prices for the past 72 hours are calculated based on snapshots taken of the price at 2 minute intervals. This helps smooth the fluctuation of prices during periods of network congestion.

Given that fees are charged in DAI, but are charged to the bridge in Ether, we calculate the moving average exchange rate using the previous 7 days ETH/DAI exchange rates, with an adjustment factor of one standard deviation to reduce the effects of exchange rate volatility.

Once we have calculated the fee in DAI, we update the relevant fee information in the bridge smart contracts.

There may be times where you will pay a little more than the actual transaction costs, and other times when you will pay a little less. Given that the prices are being updated more frequently, they should be closer to the actual cost.

We are currently evaluating and planning the migration steps to integrate updated contracts that use less gas, which will lead to lower fees in the future.