Deploying Contracts
Different ways to deploy your contracts to Mantle Network
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.
Using Remix IDE
Remix‘s web-based IDE supports writing, testing, debugging, and deploying smart contracts written in Solidity, Yul, and other popular contract development languages.
Start by opening Remix in your browser. Create a new
.sol
file under the "Contracts" folder and start writing your code.
The JSON file containing the bytecode generated upon compiling your contract can be found in the "build-info" directory.
Upon successful deployment, you'll be able to see the transaction and contract info in the terminal at the bottom, like so:
Using Hardhat
Hardhat 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.
Start by creating a new Hardhat project and configuring the
hardhat.config.js
file to add Mantle Network's settings to it.
With your contracts ready in the "Contracts" directory within your Hardhat project, you can run the following command to compile them.
Use the following command to deploy your contracts to a chosen network.
Refer to the Troubleshooting page if you run into issues while deploying your contract.
Using Foundry
Foundry 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: used to compile, test, and deploy contracts
Cast: used to make RPC calls to interact with a network
Use the following command to compile a smart contract.
Sample Output
Upon successful compilation, use the following command to deploy a smart contract
Sample Output
Using Thirdweb CLI
You can install the thirdweb CLI globally on your machine using npm
by running the following command.
Creating a Project
Start by creating a new project by running:
Input your preferences for the command line prompts:
Give your project a name
Choose your preferred framework: Hardhat or Foundry
Name your smart contract
Add any desired extensions
Once created, navigate to your project’s directory and open in your preferred code editor. If you open the
contracts
folder, you will find your smart contract; this is your smart contract written in Solidity.The following is code for an ERC721Base contract without specified extensions. It implements all of the logic inside the
ERC721Base.sol
contract; which implements theERC721A
standard.
This contract inherits the functionality of ERC721Base through the following steps:
Importing the ERC721Base contract
Inheriting the contract by declaring that our contract is an ERC721Base contract
Implementing any required methods, such as the constructor.
After modifying your contract with your desired custom logic, you're ready to deploy it to Mantle using Deploy.
You can also navigate to the thirdweb Explore page and choose from a collection of pre-built contracts to use and deploy. For more information on different contracts available on Explore, check out thirdweb’s documentation.
Deploying Contract
deploy
allows you to deploy a smart contract to Mantle Network without configuring RPC URLs, exposing your private keys, writing scripts, and other additional setup such as verifying your contract.
To deploy your smart contract using deploy, navigate to the root directory of your project and run:
Executing this command will trigger the following actions:
Compiling all the contracts in the current directory.
Providing the option to select which contract(s) you wish to deploy.
Uploading your contract source code (ABI) to IPFS.
When it is completed, it will open a dashboard interface to finish filling out the parameters for our contract.
_name
: contract name_symbol
: symbol or "ticker"_royaltyRecipient
: wallet address to receive royalties from secondary sales_royaltyBps
: basis points (bps) that will be given to the royalty recipient for each secondary sale, e.g. 500 = 5%
Select Mantle Testnet as the network if you're deploying to the testnet, or Mantle Mainnet if you're deploying to production.
Manage additional settings on your contract’s dashboard as needed such as uploading NFTs, configuring permissions, and more.
For additional information on deploy
, refer to thirdweb’s documentation. You can reach out thirdweb support at http://support.thirdweb.com/.
Last updated