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
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.
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.
Off-chain servers that listen for particular events on the source chain and submit signed proposals to the destination chain.
Delegate calls to the handler contracts for deposits, start a transaction on the source chain, and execute the proposals on the target chain.
Palm’s handler contracts send mint/burn token transactions depending on the user input.
On Palm, target contracts are ERC-20, ERC-721 and ERC-1155 on each side of the bridge.
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.
Identifier for the transferring token’s smart contract. Resource ID is used to link the equivalent contracts on both sides of the bridge.
Identifier of the chain, for example, Palm network or Ethereum
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.
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:
- The user calls the deposit() function on Palm network’s bridge contract. The user must provide the:
- target chain - 01 for Ethereum network, 02 for Palm network)
- resource ID
- calldata, which represent a token transfer to be executed on Ethereum.
- The ERC-721 handler’s deposit() function is called, which verifies the data provided by the user.
- The bridge then locks the token on the ERC-721 contract.
- The Palm’s bridge contract then emits a deposit event containing the data that will be executed on Ethereum.
- On ChainBridge, this type of event is called a proposal.
- Once the bridge’s first relayer detects the event on Ethereum, it executes the proposal on Ethereum via the bridge.
- The proposal delegates an executeDeposit call to the ERC-721 handler contract.
- 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.
- 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.
When transferring to Ethereum, there are 2 transactions executed by the bridge on Mainnet.
- 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).
- 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:
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.