> ## Documentation Index
> Fetch the complete documentation index at: https://mantrachain.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

> [!NOTE]
>
> **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](https://explorer.dukong.io)

### Mainnet

* **RPC URL**: `https://evm.mantrachain.io`
* **Chain ID**: `5888`
* **Explorer**: [blockscout.mantrascan.io](https://blockscout.mantrascan.io)

## Method 1: Using Hardhat

Hardhat is a popular development environment for Ethereum software.

### Setup

1. **Install Node.js** (version 18.0 or higher recommended)

2. **Create a new project**:
   ```bash theme={null}
   mkdir my-project
   cd my-project
   npm init -y
   npm install --save-dev hardhat
   npx hardhat init
   ```

3. **Configure Hardhat** for MANTRA Chain by updating `hardhat.config.js`:
   ```javascript theme={null}
   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`:

```javascript theme={null}
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

```bash theme={null}
npx hardhat run scripts/deploy.js --network mantra_testnet
```

For more details, see our [Hardhat guide](https://mantrachain.mintlify.site/developers/evm/using-hardhat.md).

## Method 2: Using Foundry

Foundry is a fast, portable, and modular toolkit for Ethereum application development.

### Setup

1. **Install Foundry**:
   ```bash theme={null}
   curl -L https://foundry.paradigm.xyz | bash
   foundryup
   ```

2. **Create a new project**:
   ```bash theme={null}
   forge init my-contract
   cd my-contract
   ```

### Deploy with Forge

```bash theme={null}
forge create src/MyContract.sol:MyContract \
  --rpc-url https://evm.dukong.mantrachain.io \
  --private-key $PRIVATE_KEY \
  --chain-id 5887
```

### Using Scripts

Create `script/Deploy.s.sol`:

```solidity theme={null}
// 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:

```bash theme={null}
forge script script/Deploy.s.sol:DeployScript \
  --rpc-url https://evm.dukong.mantrachain.io \
  --private-key $PRIVATE_KEY \
  --broadcast \
  --chain-id 5887
```

For more details, see our [Foundry guide](https://mantrachain.mintlify.site/developers/evm/using-foundry.md).

## Method 3: Using Remix

Remix is a web-based IDE that makes it easy to deploy contracts without local setup.

### Steps

1. Go to [Remix IDE](https://remix.ethereum.org)
2. Create or import your Solidity contract
3. Compile your contract
4. Go to the "Deploy & Run" tab
5. Select "Injected Provider" (MetaMask)
6. 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
7. 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](https://mantrachain.mintlify.site/developers/evm/verifying-contracts.md) guide for detailed instructions.

### Interact with Your Contract

Once deployed, you can:

* View your contract on the [block explorer](https://explorer.dukong.io)
* 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](https://mantrachain.mintlify.site/developers/evm/using-precompiles.md) to interact with MANTRA Chain's unique features
* Explore [EVM development](https://mantrachain.mintlify.site/developers/evm/getting-started.md) on MANTRA Chain
* Check out our [architecture documentation](https://mantrachain.mintlify.site/developers/architecture/overview.md) to understand MANTRA Chain's capabilities
* Join our [Discord](https://discord.com/invite/mantrachain) community for support

## Resources

* [Deploying Contracts Guide](https://mantrachain.mintlify.site/developers/evm/deploying-contracts.md) - Detailed deployment documentation
* [EVM Getting Started](https://mantrachain.mintlify.site/developers/evm/getting-started.md) - Complete EVM development guide
* [Network Details](https://mantrachain.mintlify.site/resources/network-details.md) - Network information and endpoints


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.