Comment on page
Adding Mantle to a CEX
Mantle network shares the Ethereum JSON-RPC API with almost no differences. You can choose to connect to Mantle through any of the following means:
- 1.
- 2.
- 3.
On Mantle network, the $ETH balance of an account is not stored as part of the account's state, but as an ERC-20 balance at address
0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111
. You can still access it using the standard APIs.The ERC-20 contract address for a token on Mantle may be different from the address for the same token on Ethereum. The list of tokens and their addresses is here.
To get the total ERC-20 token balance of a user for a specific token we listed, you need to:
- Connect to a standard Ethereum endpoint and send a
balanceOf
query to the L1 token address. - Connect to a Mantle endpoint and send a
balanceOf
query to address.
The ERC-20 contracts on Mantle function the same way they do on Ethereum, so you can use your existing code for withdrawals and deposits. Just connect to a Mantle endpoint.
Most of the cost of a Mantle transaction is not the gas consumed by the transaction itself (which is priced at a very low level), but the cost of writing the transaction in Ethereum. That cost is deducted automatically from the user's balance on Mantle. If you charge your users the cost of withdrawals, you have to account for it.
You can read more about this subject at Transaction Fees on L2. You can also find relevant code samples on our Mantle Tutorial page.
As a centralized exchange, there will be times that withdrawals of $ETH/$MNT token or an ERC-20 token on either Mantle network or Ethereum exceed deposits and you need to transfer assets. To do that you use a bridge or a gateway. We have a standard bridge that receives assets on Ethereum mainnet, and mints the equivalent asset on Mantle network.
When a user wants to withdraw the assets back to L1, the bridge burns the asset on L2 and releases it to the user on L1. If you want to use this gateway automatically, follow this tutorial for bridging ETH, or this tutorial for bridging ERC-20 tokens.
Note that while L1 to L2 transactions typically take minutes, L2 to L1 transactions on the gateway require a 7 day challenge period.
When an ERC-20 token does not have a Mantle equivalent you can create one. If there is no need for custom business logic, you can follow the steps in this tutorial for bridging standard ERC-20s. If you need to implement some kind of custom logic, see this tutorial for bridging custom ERC-20s.
Last modified 4mo ago