Mantle 백서

Mantle

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 37쪽 중 33쪽

m RPC providers * Broad and deep multi-chain data at scale * Enterprise-grade performance [**Sign up here to start building on Mantle**](https://www.covalenthq.com/platform/?utm_source=mantle\&utm_medium=partner-docs)**.** Here's a guide to help you get started: {% content-ref url="/pages/wZPzcTKJKBHAnj65yr7c" %} [Covalent Data Indexing API](/network/network/for-devs/resources-and-tooling/covalent-data-indexing-api) {% endcontent-ref %} Check out their docs by following the link below. {% embed url="<https://www.covalenthq.com/docs/networks/mantle/>" %} ## Unmarshal Unmarshal provides an API, TS and Golang SDK, and a data parser to fetch indexed on-chain data and conveniently plug it into your dApps. You can also find analytics data available at a glance for multiple chain, including Mantle. Follow the link below to navigate to the Unmarshal console and get started. {% embed url="<https://console.unmarshal.io>" %} ## DefiLlama DefiLlama is a multi-chain TVL stats dashboard, where data connectors contributed and maintained by a community. Follow the link below to see data for Mantle Network. {% embed url="<https://defillama.com/chain/Mantle>" %} ## SubQuery [SubQuery](https://academy.subquery.network/) is a fast, flexible, and reliable open-source data indexer that provides custom APIs for dApps and web3 systems across [multiple chains](https://subquery.network/networks), including Mantle Network. Follow the link below to get started. {% embed url="<https://academy.subquery.network/quickstart/quickstart_chains/mantle.html>" %} ## DEXTools DEXTools is a platform that provides users with a comprehensive set of tools and resources to navigate the DeFi ecosystem. It supports swapping and trading assets that are deployed to Mantle Network and other chains using different decentralized exchanges. {% embed url="<https://www.dextools.io/app/en/pairs>" %} ## DEX Screener DEX Screener is an online tool that supports real-time blockchain analytics and allows users to filter through a variety of assets across decentralized exchanges to perform price analysis. {% embed url="<https://dexscreener.com/>" %} ## DeBank DeBank is a defi dashboard that enables users to track their portfolio, access data and analytics for decentralized lending protocols, stablecoins, margin trading platforms and DEXes. Developers can integrate API end-points including information about users, chains, protocols and tokens in their programmes. {% embed url="<https://debank.com/>" %} # Cross-chain Messaging ## LayerZero [LayerZero](https://layerzero.gitbook.io/docs/) is an omnichain interoperability protocol that enables cross-chain messaging. Applications built on Mantle Network can use the LayerZero protocol to connect to 35+ supported blockchains seamlessly.&#x20; LayerZero Endpoint has been deployed on Mantle Network, and developers building on Mantle can leverage the LayerZero protocol to build cross-chain capabilities. LayerZero’s Endpoint ULNv2 validation library relies on two parties, the Oracle and Relayer, to transfer messages between on-chain endpoints. When LayerZero sends a message from Mantle to chain X, the message is routed through the endpoint on Mantle to the ULNv2 validation library. The ULNv2 library notifies the Oracle and Relayer of the message and its destination chain X. The Oracle forwards the packet hash to the endpoint on chain X, and the Relayer submits the packet to be verified on-chain against the hash and delivers the message. As a developer, LayerZero Endpoint is the only interface for your User Application (UA). The Endpoint allows UAs to configure the Messaging Library for sending and receiving verified messages and guarantees the message-delivering ordering across all messaging libraries. * `Send()`: the message will be sent through the endpoint first and then redirected to the UA-configured Messaging Library. * `Receive()`: the message will be verified at the Messaging Library first then forwarded to the endpoint and eventually delivered to the UA.&#x20; ### Links * Learn how to [integrate LayerZero](https://layerzero.gitbook.io/docs/evm-guides/master/how-to-send-a-message) into your contracts and look at the deployed contracts for [Mainnet](https://layerzero.gitbook.io/docs/technical-reference/mainnet/supported-chain-ids) and [Testnet](https://layerzero.gitbook.io/docs/technical-reference/testnet/testnet-addresses#layerzero-endpoints-testnet) usage. * Find examples on LayerZero's [Github](https://github.com/LayerZero-Labs/solidity-examples). * See [how to send a LayerZero message](https://layerzero.gitbook.io/docs/evm-guides/master/how-to-send-a-message). ## Axelar [Axelar](https://docs.axelar.dev/) is a decentralized cross-chain communication network that enables interoperability by connecting different heterogenous chains. It is secured by a Proof-of-Stake (PoS) consensus mechanism and can enable asset transfer and message passing between chains by allowing contracts to interact with each other using [General Message Passing (GMP)](https://docs.axelar.dev/dev/general-message-passing/overview). ### Squid x Axelar Squid is the cross-chain swap and liquidity routing protocol on [Axelar Network](https://axelar.network/). It supports canonically swapping and sending any native token between chains. Swaps are composable with Axelar's generalized message passing, so Squid can enable *one-click* transactions between any application and any user, using any asset. This can be done using [Squid's TS SDK](https://www.npmjs.com/package/@0xsquid/sdk), the [Squid web app](https://app.squidrouter.com/), or the contracts directly. ### Links #### Axelar * See examples of how to use Axelar to implement common dApp use cases in an EVM environment in this [GitHub repo](https://github.com/axelarnetwork/axelar-examples/blob/main/examples/evm/README.md). * You can find more descriptive guides in the Axelar dev docs: * [How to send tokens between chains](https://docs.axelar.dev/dev/send-tokens/overview) * [How to call smart contract functions across blockchains](https://docs.axelar.dev/dev/general-message-passing/overview) * Other reference material can also be found in the Axelar dev docs: * [Axelar SDK docs](https://docs.axelar.dev/dev/axelarjs-sdk/intro) * [Chain names](https://docs.axelar.dev/dev/reference/mainnet-chain-names) * See [how to add Mantle Network to an Axelar validator node](https://docs.axelar.dev/validator/external-chains/mantle) if you're looking to deploy one. * If you're looking for support: * [Community support on Stackoverflow](https://stackoverflow.com/questions/ask?tags=axelar) * [Axelar Discord](https://discord.gg/aRZ3Ra6f7D) #### Squid * [Squid SDK reference docs](https://docs.squidrouter.com/sdk) # Oracles Oracles enable access to reliable off-chain data and information that might be necessary for for smart contracts to enable specific use cases.&#x20; The most common requirement is token prices for different token pairs. There are more complex use cases as well, for example: * Dynamic NFTs that have variable properties that can change based on events that happen in the real world * Some dApps require access to a reliable source of random numbers Oracles are essentially API services that smart contracts can use to fetch off-chain data. ## API3 API3 is building secure first-party oracles on Mantle. API3 is live with three parts: * **dAPIs**: First-party aggregated data feeds sourced directly from the data providers. {% embed url="<https://docs.api3.org/guides/dapis/subscribing-managed-dapis/>" %} * **Airnode** - The first-party serverless Oracle solution to bring any REST API on-chain. {% embed url="<https://docs.api3.org/guides/airnode/calling-an-airnode/>" %} * **QRNG** - Quantum Random Number Generator for verifiable quantum RNG on-chain. {% embed url="<https://docs.api3.org/guides/qrng/>" %} ## SupraOracles SupraOracles provides access to reliable price feeds on multiple chains, and Verifiable Random Function (VRF). Check out their docs to find out more. {% embed url="<https://supraoracles.com/docs>" %} SupraOracles now supports the Mantle mainnet, including various trading pairs such as&#x20; * [mETH/wETH](https://supraoracles.com/data/catalog/details?instrumentName=meth_weth\&providerName=supra) * [MNT/USDT](https://supraoracles.com/data/catalog/details?instrumentName=mnt_usdt\&providerName=supra) * [MINU/WMNT](https://supraoracles.com/data/catalog/details?instrumentName=minu_wmnt\&providerName=supra) ## Pyth Network Pyth network is an oracle that publishes financial market data to multiple blockchains. They aggregate price data and provide price feeds for different asset types such as US equities, commodities, and other cryptocurrencies. Check out their docs for more info. {% embed url="<https://docs.pyth.network/>" %} ## RedStone RedStone is a data ecosystem that delivers frequently updated, reliable and diverse data for your dApp and smart contracts. Check out their docs for more info. {% embed url="<https://docs.redstone.finance/docs/introduction>" %} # Particle AA SDK Particle Network Smart Wallet-as-a-Service Integration [**Particle Network**](https://particle.network) is an intent-centric, modular access layer of web3 applications. With Particle's Smart Wallet-as-a-Service, developers can curate an unparalleled user experience through modular and customizable EOA/AA embedded wallet components. Using MPC-TSS for key management, Particle can streamline user onboarding via familiar web2 accounts - such as Google accounts, email addresses, and phone numbers. Particle supports Mantle Mainnet and Testnet through both EOA interactions and native ERC-4337 SimpleAccount implementations. Using Particle Network Wallet-as-a-Service for a secure, flexible embedded EOA wallet implementation on Mantle Mainnet and Testnet is quite simple and can be achieved through a mechanism like the one below. 1. **Create a ParticleNetwork instance.** ```js import { ParticleNetwork } from "@particle-network/auth"; import { Mantle, MantleTestnet } from "@particle-network/chains"; import { SmartAccount } from "@particle-network/aa"; // Retrieved from https://dashboard.particle.network const config = { projectId: "xx", clientKey: "xx", appId: "xx", }; const particle = new ParticleNetwork({ ...config, chainName: Mantle.name, chainId: Mantle.id, }); await particle.auth.login() // Initiates social login ``` 2. **Introducing** [**ERC-4337**](https://eips.ethereum.org/EIPS/eip-4337) **account abstraction into Particle instance.** Instead facilitating interaction with Mantle through a smart account can be achieved through the following: ```js import { ParticleNetwork } from "@particle-network/auth"; import { Mantle, MantleTestnet } from "@particle-network/chains"; import { SmartAccount } "@particle-network/aa"; // Retrieved from https://dashboard.particle.network const config = { projectId: "xx", clientKey: "xx", appId: "xx", }; const particle = new ParticleNetwork({ ...config, chainName: Mantle.name, chainId: Mantle.id, }); // If using AA const smartAccount = new SmartAccount(new ParticleProvider(particle.auth), { ...config, aaOptions: { simple: [{ chainId: Mantle.id, version: '1.0.0' }] } }); particle.setERC4337({ name: 'SIMPLE', version: '1.0.0' }); await particle.auth.login() // Initiates social login ``` ### Get Started * [Particle Dashboard](https://dashboard.particle.network/) * [Particle Documentation](https://docs.particle.network/) * [Mantle Example Integration Gist](https://gist.github.com/TABASCOatw/c36f1f2531f29c63d6ee88f0f8ff7397) # Tutorials Examples and walkthroughs to refer to and follow along # Deploying Contracts Different ways to deploy your contracts to Mantle Network {% hint style="danger" %} 2023/12/04 Thirdweb released a report about recent security vulnerabilities in the commonly used open-source library for web3 smart contracts. All developers who have previously deployed contracts are advised to ensure that the contract is secure, see details [here](https://blog.thirdweb.com/security-vulnerability/). {% endhint %} ## Using Remix IDE [Remix‘s web-based IDE](https://remix.ethereum.org/) supports writing, testing, debugging, and deploying smart contracts written in Solidity, Yul, and other popular contract development languages.&#x20; 1. Start by opening Remix in your browser. Create a new `.sol` file under the **"Contracts"** folder and start writing your code. <figure><img src="https://3701411312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNHXgeqhgrznnRobzznxl%2Fuploads%2F5cUbKRxA1jDK20U899fH%2Fimage.png?alt=media&amp;token=9d3a2883-e4d8-484b-9443-32238d3b0f3a" alt=""><figcaption></figcaption></figure> 2. Once ready, you can proceed with compiling the contract by either clicking the <img src="https://3701411312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNHXgeqhgrznnRobzznxl%2Fuploads%2Fvr4YTgS6Nr6TQe3p0ZJt%2Fimage.png?alt=media&amp;token=4093e780-38be-49bc-87ce-d15f2bec6f51" alt="" data-size="line"> button on the top, or clicking on the blue button that says **"Compile \<file\_name>",** which you can access by navigating to the **"Solidity Compiler"** tab by clicking on the <img src="https://3701411312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNHXgeqhgrznnRobzznxl%2Fuploads%2FBcapVa4JsD1Eygl6xOWq%2Fimage.png?alt=media&amp;token=1d12d8e0-3107-4941-ae03-17b8a93b47d3" alt="" data-size="line"> button. {% hint style="info" %} The JSON file containing the bytecode generated upon compiling your contract can be found in the **"build-info"** directory. {% endhint %} <figure><img src="https://3701411312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNHXgeqhgrznnRobzznxl%2Fuploads%2F2SZNZJxv5TZ4VWjsmE1o%2Fimage.png?alt=media&amp;token=494bf35f-1b55-4f33-8b94-ae9d7f095b70" alt=""><figcaption></figcaption></figure> 3. If the compilation was successful (shown as <img src="https://3701411312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNHXgeqhgrznnRobzznxl%2Fuploads%2F2MdgamaTNkm4gApmREpi%2Fimage.png?alt=media&amp;token=7f1d893f-e2d8-45ed-99dd-b490c4bf3be7" alt="" data-size="line"> in the navigation bar), you'll be able to deploy the contract from the **"Deploy and Run Transactions"** tab, which can be accessed by clicking on the <img src="https://3701411312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNHXgeqhgrznnRobzznxl%2Fuploads%2FftwSLlCO0aSe3e4Bf53Y%2Fimage.png?alt=media&amp;token=8122f488-1075-4d36-8015-d4d8e1930810" alt="" data-size="line"> button. Switch to Mantle Network in your MetaMask wallet and select **"Injected Provider - MetaMask"** from the **"Environment"** dropdown list and select a wallet account that will be used to pay the gas fees. Remix will automatically connect to network that the wallet is currently connected to. Click on the <img src="https://3701411312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNHXgeqhgrznnRobzznxl%2Fuploads%2FT9rRAIE665XU0ciG6Udd%2Fimage.png?alt=media&amp;token=4a8d53c0-c858-4d0c-a8ea-7d8609201524" alt="" data-size="line"> button to send the deploy transaction. {% hint style="info" %} In case you haven't added Mantle Network to your wallet yet, click on the <img src="https://3701411312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNHXgeqhgrznnRobzznxl%2Fuploads%2FKDSbXdiQ4WGn743h4uci%2Fimage.png?alt=media&amp;token=8cbee08e-456d-434c-838e-a1e0791551c2" alt="" data-size="line"> icon next to the **"Environment"** label. This will take you to Chainlist's website where you can look up Mantle Mainnet and Testnet settings and add them to your wallet. {% endhint %} <figure><img src="https://3701411312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNHXgeqhgrznnRobzznxl%2Fuploads%2FibRS7R3g7QzHn1qa8J0H%2Fimage.png?alt=media&amp;token=385565f6-20f7-4195-8f33-658d2ee3abb0" alt=""><figcaption></figcaption></figure> Upon successful deployment, you'll be able to see the transaction and contract info in the terminal at the bottom, like so: <figure><img src="https://3701411312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNHXgeqhgrznnRobzznxl%2Fuploads%2FTzYBxl1T0ytSdFca6Snc%2Fimage.png?alt=media&amp;token=1798f1d9-4559-42d8-bb16-52c94b5e9da7" alt=""><figcaption></figcaption></figure> ## Using Hardhat [Hardhat](https://hardhat.org/hardhat-runner/docs/getting-started#overview) is a smart contract development environment that comes with tools that can be used to compile, debug, and deploying Solidity smart contracts and dApps on Ethereum and other EVM-compatible chains like Mantle Network. 1. Start by [creating a new Hardhat project](https://hardhat.org/hardhat-runner/docs/guides/project-setup) and configuring the `hardhat.config.js` file to add Mantle Network's settings to it. ```javascript import { HardhatUserConfig } from "hardhat/config"; import "@nomicfoundation/hardhat-toolbox"; import * as dotenv from 'dotenv'; dotenv.config(); const config: HardhatUserConfig = { solidity: "0.8.19", // solidity version defaultNetwork: "mantleTest", // chosen by default when network isn't specified while running Hardhat networks: { mantle: { url: "https://rpc.mantle.xyz", //mainnet accounts: [process.env.ACCOUNT_PRIVATE_KEY ?? ''], }, mantleTest: { url: "https://rpc.testnet.mantle.xyz", // testnet accounts: [process.env.ACCOUNT_PRIVATE_KEY ?? ''] } }, etherscan: { apiKey: process.env.API_KEY, }, }; export default config; ``` 2. With your contracts ready in the **"Contracts"** directory within your Hardhat project, you can run the following command to compile them.&#x20; ```bash npx hardhat compile Compiling... Compiled 1 contract successfully ``` 3. Use the following command to deploy your contracts to a chosen network. ```bash npx hardhat run --network mantleTest scripts/deploy.ts Contract deployed to address: 0x0000000000000000000000000000000000000000 ``` {% hint style="info" %} Refer to the [Troubleshooting](/network/network/for-devs/troubleshooting) page if you run into issues while deploying your contract. {% endhint %} ## Using Foundry [Foundry](https://github.com/foundry-rs/foundry#readme) is a fast, portable and modular toolkit for EVM application development written in Rust. The two main components that you'll generally be using for smart contract development are: * [Forge](https://github.com/foundry-rs/foundry/tree/master/crates/forge#readme): used to compile, test, and deploy contracts * [Cast](https://github.com/foundry-rs/foundry/tree/master/crates/cast#readme): used to make RPC calls to interact with a network 1. Use the following command to compile a smart contract. ```bash forge build ``` #### Sample Output ``` [⠊] Compiling... [⠑] Installing solc version 0.8.21 [⠰] Successfully installed solc 0.8.21 [⠒] Compiling 22 files with 0.8.21 [⠃] Solc 0.8.21 finished in 3.19s Compiler run successful! ``` 2. Upon successful compilation, use the following command to deploy a smart contract {% code overflow="wrap" %} ```bash forge create --rpc-url https://rpc.testnet.mantle.xyz --private-key <your-private-key> src/Storage.sol:Storage --legacy ``` {% endcode %} #### Sample Output ``` [⠢] Compiling... No files changed, compilation skipped Deployer: 0x... Deployed to: 0x... Transaction hash: 0x... ``` ## Using Thirdweb CLI You can install the thirdweb CLI globally on your machine using `npm` by running the following command. ```bash npm i -g @thirdweb-dev/cli ``` ### Creating a Project 1. Start by creating a new project by running: ```bash npx thirdweb create contract ``` 2. Input your preferences for the command line prompts: 1. Give your project a name 2. Choose your preferred framework: Hardhat or Foundry 3. Name your smart contract 4. Choose the type of base contract: Empty, [ERC20](https://portal.third
프로젝트로 돌아가기