EVM Development
Deploy a Smart Contract on MANTRA Chain
Learn how to deploy your first smart contract on MANTRA Chain using standard EVM tools
MANTRA Chain is fully EVM-compatible, which means you can deploy Solidity smart contracts using familiar tools like Hardhat, Foundry, or Remix.
Info
Full EVM Compatibility: Deploy Solidity smart contracts using standard EVM tooling - no need to learn new languages!
Prerequisites
Before deploying, make sure you have:
- A funded wallet with MANTRA tokens for gas fees
- Your contract compiled and ready to deploy
- Network configuration set up
Network Configuration
Testnet (DuKong)
- RPC URL:
https://evm.dukong.mantrachain.io - Chain ID:
5887 - Explorer: explorer.dukong.io
Mainnet
- RPC URL:
https://evm.mantrachain.io - Chain ID:
5888 - Explorer: blockscout.mantrascan.io
Method 1: Using Hardhat
Hardhat is a popular development environment for Ethereum software.
Setup
-
Install Node.js (version 18.0 or higher recommended)
-
Create a new project:
mkdir my-project cd my-project npm init -y npm install --save-dev hardhat npx hardhat init -
Configure Hardhat for MANTRA Chain by updating
hardhat.config.js:require("@nomicfoundation/hardhat-toolbox"); module.exports = { solidity: "0.8.23", networks: { mantra_mainnet: { url: "https://evm.mantrachain.io", chainId: 5888, accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [], }, mantra_testnet: { url: "https://evm.dukong.mantrachain.io", chainId: 5887, accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [], }, }, };
Create Deployment Script
Create scripts/deploy.js:
const hre = require("hardhat");
async function main() {
const MyContract = await hre.ethers.getContractFactory("MyContract");
const myContract = await MyContract.deploy();
await myContract.waitForDeployment();
const address = await myContract.getAddress();
console.log("Contract deployed to:", address);
console.log("Explorer:", `https://explorer.dukong.io/address/${address}`);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});Deploy
npx hardhat run scripts/deploy.js --network mantra_testnetFor more details, see our Hardhat guide.
Method 2: Using Foundry
Foundry is a fast, portable, and modular toolkit for Ethereum application development.
Setup
-
Install Foundry:
curl -L https://foundry.paradigm.xyz | bash foundryup -
Create a new project:
forge init my-contract cd my-contract
Deploy with Forge
forge create src/MyContract.sol:MyContract \
--rpc-url https://evm.dukong.mantrachain.io \
--private-key $PRIVATE_KEY \
--chain-id 5887Using Scripts
Create script/Deploy.s.sol:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Script, console} from "forge-std/Script.sol";
import {MyContract} from "../src/MyContract.sol";
contract DeployScript is Script {
function run() external {
vm.startBroadcast();
MyContract myContract = new MyContract();
console.log("Contract deployed to:", address(myContract));
vm.stopBroadcast();
}
}Deploy:
forge script script/Deploy.s.sol:DeployScript \
--rpc-url https://evm.dukong.mantrachain.io \
--private-key $PRIVATE_KEY \
--broadcast \
--chain-id 5887For more details, see our Foundry guide.
Method 3: Using Remix
Remix is a web-based IDE that makes it easy to deploy contracts without local setup.
Steps
- Go to Remix IDE
- Create or import your Solidity contract
- Compile your contract
- Go to the "Deploy & Run" tab
- Select "Injected Provider" (MetaMask)
- Make sure MetaMask is connected to MANTRA Chain
- Add MANTRA Chain network if needed:
- Network Name: MANTRA Chain Testnet
- RPC URL:
https://evm.dukong.mantrachain.io - Chain ID:
5887 - Currency Symbol: MANTRA
- Add MANTRA Chain network if needed:
- Deploy your contract
After Deployment
Verify Your Contract
After deployment, verify your contract on the block explorer. This allows others to view and interact with your contract source code.
See our Verifying Contracts guide for detailed instructions.
Interact with Your Contract
Once deployed, you can:
- View your contract on the block explorer
- Interact with it using the explorer's contract interaction features
- Build a frontend application to interact with your contract
Next Steps
- Learn about using precompiles to interact with MANTRA Chain's unique features
- Explore EVM development on MANTRA Chain
- Check out our architecture documentation to understand MANTRA Chain's capabilities
- Join our Discord community for support
Resources
- Deploying Contracts Guide - Detailed deployment documentation
- EVM Getting Started - Complete EVM development guide
- Network Details - Network information and endpoints