bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 37쪽 중 30쪽
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>// 0x50 range - 'storage' and execution.</p><p>const ( </p><p> POP OpCode = 0x50 </p><p> MLOAD OpCode = 0x51 </p><p> MSTORE OpCode = 0x52 </p><p> MSTORE8 OpCode = 0x53 </p><p> SLOAD OpCode = 0x54 </p><p> SSTORE OpCode = 0x55 </p><p> JUMP OpCode = 0x56 </p><p> JUMPI OpCode = 0x57 </p><p> PC OpCode = 0x58 </p><p> MSIZE OpCode = 0x59</p><p> GAS OpCode = 0x5a </p><p> JUMPDEST OpCode = 0x5b </p><p> <mark style="color:red;">PUSH0 OpCode = 0x5f</mark> </p><p>)</p> | <p>// 0x50 range - 'storage' and execution. const ( </p><p> POP OpCode = 0x50 + iota </p><p> MLOAD </p><p> MSTORE </p><p> MSTORE8 </p><p> SLOAD </p><p> SSTORE </p><p> JUMP </p><p> JUMPI </p><p> PC </p><p> MSIZE </p><p> GAS </p><p> JUMPDEST </p><p>)</p> |
### 0xf0 range - ‘`INVALID`’
Introduced in [EIP141](https://eips.ethereum.org/EIPS/eip-141)
| EVM | Mantle VM |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>// 0xf0 range - closures. </p><p>const ( </p><p> CREATE OpCode = 0xf0 </p><p> CALL OpCode = 0xf1 </p><p> CALLCODE OpCode = 0xf2 </p><p> RETURN OpCode = 0xf3 </p><p> DELEGATECALL OpCode = 0xf4</p><p> CREATE2 OpCode = 0xf5</p><p></p><p> STATICCALL OpCode = 0xfa </p><p> REVERT OpCode = 0xfd </p><p> <mark style="color:red;">INVALID OpCode = 0xfe</mark> </p><p> SELFDESTRUCT OpCode = 0xff </p><p>)</p> | <p>// 0xf0 range - closures. </p><p>const ( </p><p> CREATE OpCode = 0xf0 + iota </p><p> CALL </p><p> CALLCODE </p><p> RETURN </p><p> DELEGATECALL </p><p> CREATE2 </p><p> STATICCALL = 0xfa</p><p></p><p> REVERT = 0xfd </p><p> SELFDESTRUCT = 0xff </p><p>)</p> |
## Troubleshooting
Follow the link below to see solutions and fixes for issues that hackers commonly encounter.
{% content-ref url="/pages/gZgi8yvsoz1BRgHs9veS" %}
[Troubleshooting](/network/network/for-devs/troubleshooting)
{% endcontent-ref %}
## Support
<table><thead><tr><th width="136" align="center">Channel</th><th>Link</th></tr></thead><tbody><tr><td align="center"><strong>Discord</strong></td><td><a href="https://discord.com/invite/0xMantle">https://discord.com/invite/0xMantle</a></td></tr><tr><td align="center"><strong>Telegram</strong></td><td><a href="https://t.me/mantledevs">https://t.me/mantledevs</a></td></tr></tbody></table>
* If you’re a partner - Please get in touch with us by tagging any relevant team members in **"Mantle <> your org’s"** telegram chat
* If you’re a hacker building on Mantle Network - Please reach out to us via our official Discord channel or Mantle Devs telegram channel
* If you’re a developer just trying out the network - Please reach out to us via Discord in the **#dev-discussions** channel, or raise a ticket for fast response
# Common Use Cases
# Moving Assets and Data
Moving assets between Mantle and Ethereum
{% hint style="danger" %}
Mantle v2 Tectonic has been released, please move to the new [documentation](https://docs-v2.mantle.xyz/)!
{% endhint %}
The process of moving assets or data between two blockchains is generally referred to as 'bridging'. Since Mantle network is a separate Layer 2 (L2) blockchain system, apps and wallets moving assets or any another arbitrary form of data between Ethereum and Mantle can use our official bridge to achieve that.
## Sending Assets
The [Mantle Bridge](https://bridge.mantle.xyz) enables all functionality necessary for the most common use case, i.e., moving tokens between Mantle network and Ethereum. It also allows you to easily create L2 representations of existing tokens on Ethereum.
## Sending Data
If you need to send arbitrary data between Ethereum & Mantle network, you can do so by having a contract on Ethereum trigger a contract function on Mantle and vice versa. The [Mantle Bridge](https://bridge.mantle.xyz) has a simple API for triggering a cross-chain function call.
## How does it work?
The standard Mantle bridge is essentially a set of smart contracts. The two main contracts that implement the ERC-20 asset bridging mechanism are [`L2StandardBridge`](https://github.com/mantlenetworkio/mantle/blob/main/packages/contracts/contracts/L2/messaging/L2StandardBridge.sol) on Mantle network, and [`L1StandardBridge`](https://github.com/mantlenetworkio/mantle/blob/main/packages/contracts/contracts/L1/messaging/L1StandardBridge.sol) on Ethereum. Deposit or withdrawal transactions sent to the bridge by a wallet on L2 or L1 trigger specific methods in the standard bridge contracts. 
For instance, when a wallet sends a deposit request for 10 $MNT on L1, these tokens get locked on L1 in the bridge contract, and the matching amount of 10 $MNT is minted on L2 and transferred to the wallet.
In case a wallet makes a withdrawal of 10 $MNT on L2, these tokens are burned and the matching amount of 10 $MNT tokens locked on L1 get released and transferred to the wallet.
You can connect your wallet to the [Mantle Bridge UI](https://bridge.mantle.xyz) to make simple deposits and withdrawals directly. However, if you're looking to use the bridge API instead, refer to the [Mantle Bridge API](/network/network/for-devs/resources-and-tooling/mantle-bridge-api) page for more information and tutorials on how to call the appropriate SDK methods to bridge the various kinds of tokens that are currently supported.
## Using the Official Mantle Bridge
To move your $MNT tokens/Ether/other ERC-20 tokens between the Mantle and Ethereum chain, visit the [Mantle Bridge](https://bridge.mantle.xyz). Feel free to try out the testnet bridge first to get yourself acquanted with the UI. You can find the detailed steps here: [Using Mantle Bridge](/network/network/introduction/how-to-guides/using-mantle-bridge)
# Adding Mantle Wallet Support
{% hint style="danger" %}
Mantle v2 Tectonic has been released, please move to the new [documentation](https://docs-v2.mantle.xyz/)!
{% endhint %}
### **Overview**
Mantle network uses $MNT as a native token, and creates an EVM-like code execution environment for transaction and state processing. This means a user on Layer 2 (L2) can use **$MNT** exactly like they would $ETH on Ethereum, namely to pay gas fees. For this reason, there are changes to how fees are calculated on Mantle network, which you can better understand in the section:[Transaction Fees on L2](/network/network/introduction/transaction-fees-on-l2). Any $MNT tokens collected on the L2 as transaction gas fee will be rewarded to validators or burned out on schedule.
### **Connecting to Mantle**
Mantle network shares the [Ethereum JSON-RPC API](https://eth.wiki/json-rpc/API) with almost no differences. You can choose to connect to Mantle through any of the following means:
1. Our rate-limited public endpoint: [https://rpc.mantle.xyz](https://rpc.testnet.mantle.xyz)
2. Private endpoints from infrastructure providers (See [Node RPC Providers](/network/network/for-devs/resources-and-tooling/node-rpc-providers))
3. Or, by running your own node (See [Deploying a Rollup Verifier/Replica Node](/network/network/for-validators/deploy-a-node/deploying-a-rollup-verifier-replica-node))
### **Canonical Token Addresses** 
The ERC-20 contract address for a token on Mantle network may be different from the address for the same token on Ethereum. Mantle maintains a [token list](https://github.com/mantlenetworkio/mantle-token-lists) that includes known addresses for many popular tokens. 
For example, looking at the **$MNT** token, the Mantle token list returns the following addresses:
<table><thead><tr><th width="181">ChainID</th><th width="159.33333333333331">Network</th><th>Address</th></tr></thead><tbody><tr><td>1</td><td>Ethereum</td><td>0x1A4b46696b2bB4794Eb3D4c26f1c55F9170fa4C5</td></tr><tr><td>5000</td><td>Mantle Mainnet</td><td>0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000</td></tr><tr><td>5</td><td>Goerli</td><td>0xc1dC2d65A2243c22344E725677A3E3BEBD26E604</td></tr><tr><td>5001</td><td>Mantle Testnet</td><td>0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000</td></tr></tbody></table>
### **Transaction Status**
A transaction on Mantle network can be in one of these states:
* **Sequencer Confirmed:** The transaction has been accepted by the sequencer on Mantle (L2) 
* **Confirmed On-Chain:** The transaction has been written to Ethereum (L1)
If a transaction is a withdrawal, it can be in one of the following states:
* **Waiting:** Confirmed on L1, but still in the challenge period 
* **Ready for Relay:** Transaction is out of the challenge period, and can be released by submitting a relay message 
* **Relayed:** A withdrawal is finalized, and the token is released from the bridge
You can use the [Mantle SDK](https://github.com/mantlenetworkio/mantle/tree/main/packages/sdk) to find out your transaction status.
### Transaction Fees
Mantle network aims to be EVM-compatible, you can see a summary of the few differences between Mantle and Ethereum [here](/network/network/introduction/transaction-fees-on-l2).
### Estimating Total Fees
The major portion of the total cost of a transaction on Mantle network comes from the cost of publishing the transaction to Ethereum. Unlike with L2 execution gas fees, users cannot specify a particular gas price or gas limit for this portion of their transaction cost when it rolls up to Ethereum. 
In fact, this fee is automatically deducted from the user's $MNT balance on Mantle when the transaction is executed.
The total fee paid by a transaction will be a combination of the normal fee estimation formula **`(gasPrice * gasLimit)`** on L2 execution, and in addition to the estimated L1 fee for rollup.
You can read more about this subject in [Transaction Fees on L2](/network/network/introduction/transaction-fees-on-l2). 
### Sending "Max" $MNT
Many wallets allow users to send the maximum amount of a token available in the user's balance. This requires the fee for this transaction to be calculated in advance, and then deducted from the user's $MNT balance being **sent**. 
{% hint style="warning" %}
You **MUST** deduct **both** the **L2 execution fee,** and the **L1 data rollup fee** from the transaction sending amount. Otherwise, it will exceed the user's balance and the transaction will fail.
{% endhint %}
# Adding Mantle to a CEX
{% hint style="danger" %}
Mantle v2 Tectonic has been released, please move to the new [documentation](https://docs-v2.mantle.xyz/)!
{% endhint %}
### **Connecting to Mantle** 
Mantle network shares the [Ethereum JSON-RPC API](https://eth.wiki/json-rpc/API) with almost no differences. You can choose to connect to Mantle through any of the following means:
1. Our rate-limited public endpoints - [https://rpc.mantle.xyz/](https://rpc.testnet.mantle.xyz/)
2. Private endpoints from infrastructure providers (see [Node RPC Providers](/network/network/for-devs/resources-and-tooling/node-rpc-providers))
3. Or, by running your own node (see [Deploying a Rollup Verifier/Replica Node](/network/network/for-validators/deploy-a-node/deploying-a-rollup-verifier-replica-node))
### **Calculating $ETH Balance** 
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.
### **Calculating $MNT Balance**
### **Token Addresses**
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](https://github.com/mantlenetworkio/mantle-token-lists#mantle-token-list).
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.
### **Deposits and Withdrawals on Mantle**
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.
### **Transaction Fees**
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](/network/network/introduction/transaction-fees-on-l2). You can also find relevant code samples on our [Mantle Tutorial page](https://mantlenetworkio.github.io/mantle-tutorial/). 
### **Deposits and Withdrawals Across Chains** 
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](https://mantlenetworkio.github.io/mantle-tutorial/cross-dom-bridge-eth/), or this [tutorial for bridging ERC-20 tokens](https://mantlenetworkio.github.io/mantle-tutorial/cross-dom-bridge-erc20/).
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](https://mantlenetworkio.github.io/mantle-tutorial/standard-bridge-standard-token/). If you need to implement some kind of custom logic, see this [tutorial for bridging custom ERC-20s](https://mantlenetworkio.github.io/mantle-tutorial/standard-bridge-custom-token/).
# Adding a Custom Bridge to Mantle
{% hint style="danger" %}
Mantle v2 Tectonic has been released, please move to the new [documentation](https://docs-v2.mantle.xyz/)!
{% endhint %}
### **Using the Standard Bridge**
We suggest considering using the [Standard Bridge](https://bridge.mantle.xyz) first before deciding to develop a custom bridge solution. 
In the standard bridge when ERC-20 is deposited on Layer 1 (L1) and transferred to the bridge contract, it remains "locked" there while the equivalent amount is minted in the Layer 2 (L2) token. For withdrawals the opposite happens, the L2 token amount is burned then the same amount of L1 tokens is transferred to the recipient. This fund can be released after the challenge period. This implementation satisfies a wide range of requirements.
### **Building a Custom Bridge**
When the Mantle Standard bridge does not satisfy your requirements for bridging assets or data, you can deploy your custom bridge solution utilizing the same cross-domain infrastructure as the Standard bridge. For details on how cross-domain messaging works, see the [Bridging basics article](https://mantlenetworkio.github.io/mantle-tutorial/cross-dom-comm/), and also the tutorial on [depositing and withdrawing ERC-20 tokens between L1 and L2](https://mantlenetworkio.github.io/mantle-tutorial/cross-dom-bridge-erc20/).
Some reasons why the standard bridge might not work for you is for example when you cannot limit the L2 token mint and burn functions to the bridge alone (something we require for security). Also, certain custom bridges implement their own logic for managing the token supply which requires custom logic. Another case might be when you are bridging non-ERC-20 tokens (e.g. NFTs). Yet another case is when you are pooling deposits for cheaper transfers to L2.
Note that when you are building a custom bridge for ERC-20 tokens and planning to add these to the Mantle token list, we have specific requirements for the bridge contracts. These have to implement the `IL1ERC20Bridge` interface in the L1 bridge contract and `IL2ERC20Bridge` interface in the L2 bridge contract. This ensures the Mantle Gateway can support token deposits and withdrawals via this custom bridge.
To add your bridge and token to the token list, you must make a pull request against the Mantle [token list repository.](https://github.com/mantlenetworkio/mantle-token-lists#mantle-token-list) Due to the complexity of reviewing a custom bridge, you will need to deploy to Mantle testnet first, before going to production.
# Solidity Support
Solidity support and EVM compatibility on Mantle network
{% hint style="danger" %}
Mantle v2 Tectonic has been released, please move to the new [documentation](https://docs-v2.mantle.xyz/)!
{% endhint %}
Since Mantle network is EVM compatible, you can deploy any contract written in Solidity, Vyper, or any other contract development language as long as it can be compiled to EVM bytecode.
There are some key differences in Solidity opcode behavior on L1 Ethereum and L2 Mantle VM. This can impact certain operations and features when deploying your dApps on Mantle. The following table lists the opcodes that behave differently accompanied with a description.
## Opcode Differences
<table><thead><tr><th width="182.33333333333331" align="center">Opcode</th><th width="197" align="center">Solidity Equivalent</th><th>Behaviour</th></tr></thead><tbody><tr><td align="center"><code>PUSH0</code></td><td align="center">N/A</td><td>Not supported currently, and so Solidity version <code>0.8.20</code> and higher cannot be used with the default <code>shanghai</code> EVM version.<br><br>Configuring the EVM version:<br>For Solc, <a href="https://docs.soliditylang.org/en/v0.8.20/using-the-compiler.html#setting-the-evm-version-to-target">refer here</a><br>For Hardhat, <a href="https://hardhat.org/hardhat-runner/docs/guides/compile-contracts#configuring-the-compiler">refer here</a></td></tr><tr><td align="center"><code>COINBASE</code></td><td align="center"><code>block.coinbase</code></td><td>Returns a constant address <a href="https://github.com/mantlenetworkio/networks/blob/3aa49c0e1c6cc07e621b4f6ec80abd7958075610/mainnet/info/mainnet-info.yaml#L29C33-L29C33"><code>0x4200000000000000000000000000000000000011</code></a><br>Refers to the <code>BVM_SequencerFeeVault</code> contract that collects L2 gas fees</td></tr><tr><td align="center"><code>DIFFICULTY</code></td><td align="center"><code>block.difficulty</code></td><td>Returns constant <code>0</code></td></tr><tr><td align="center"><cod프로젝트로 돌아가기