Deploying a Smart Contract on MST Blockchain

Deploy Smart Contracts on MST Chain using Solidity

By Prakhar SharmaSmart Contracts
Deploying a Smart Contract on MST Blockchain

MST Blockchain is an EVM-compatible blockchain, built for high throughput and low transaction fees. In this guide, we'll walk through how to deploy a simple smart contract using Hardhat on both the MST Mainnet and Testnet.

Prerequisites

Before we begin, ensure you have the following installed:

  • Node.js (v14+)

  • npm or yarn

  • Hardhat (for compiling and deploying smart contracts)

  • A crypto wallet (like MetaMask) with some test tMSTC or real MSTC

  • Some MST Testnet tokens: Get from MST Testnet Faucet

Step 1: Setup Your Hardhat Project

Create a new Hardhat project:

mkdir mst-contract-deploy
cd mst-contract-deploy
npm init -y
npm install --save-dev hardhat
npx hardhat

Choose "Create a basic sample project", then install dependencies:
npm install @nomicfoundation/hardhat-toolbox dotenv

Step 2: Write Your Smart Contract

Inside the contracts/ folder, create a file called HelloMST.sol:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

contract HelloMST {
   string public message = "Hello MST Blockchain!";

   function updateMessage(string calldata newMessage) external {
       message = newMessage;
   }
}

Step 3: Configure Hardhat for MST Blockchain

Edit your hardhat.config.js to include MST Testnet and Mainnet:

require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config();

module.exports = {
 solidity: "0.8.17",
 networks: {
   testnet: {
     url: "https://testnetrpc.mstblockchain.com",
     chainId: 4545,
     accounts: [process.env.PRIVATE_KEY]
   },
   mainnet: {
     url: "https://mariorpc.mstblockchain.com",
     chainId: 4646,
     accounts: [process.env.PRIVATE_KEY]
   }
 }
};

Create a .env file in your root directory and add your wallet's private key:
PRIVATE_KEY=your_private_key_without_0x

Never share your private key publicly or commit it to Git.

Step 4: Deploy Script

Create a new file scripts/deploy.js:
const hre = require("hardhat");

async function main() {
 const HelloMST = await hre.ethers.getContractFactory("HelloMST");
 const contract = await HelloMST.deploy();

 await contract.deployed();

 console.log(` Contract deployed at: ${contract.address}`);
}

main().catch((error) => {
 console.error(error);
 process.exitCode = 1;
});

Step 5: Deploy to MST Testnet

Make sure you have some tMSTC in your wallet (test token), then deploy:
npx hardhat run scripts/deploy.js --network testnet

Check your contract on: https://testnet.mstscan.com

Deploy to MST Mainnet

Once you're confident, switch to mainnet (ensure you have real MSTC tokens):
npx hardhat run scripts/deploy.js --network mainnet

Verify your contract on: https://mstscan.com

Great! Thanks for sharing the verification link.

Here’s a section you can add to your blog on verifying smart contracts on MST Blockchain using Blockscout + Hardhat plugin, based on Blockscout’s Hardhat verification guide.

Smart Contract Verification on MSTScan

After deploying your Smart contract to MST Blockchain, you can verify it on MSTScan — which is powered by Blockscout.
To verify your contract using Hardhat, follow the official guide provided by Blockscout:

Verification Guide:
https://docs.blockscout.com/devs/verification/hardhat-verification-plugin

This guide will walk you through:

  • Installing the Hardhat verification plugin for Blockscout

  • Configuring your hardhat.config.js

  • Running the verification command with or without constructor arguments

Once verified, your contract will be publicly readable and interactable on MSTScan.

Check Verification

Once verified, users can:

  • Read contract methods directly from the explorer

  • Interact with the contract UI

  • Audit the source code transparently

Pro Tip

If you're verifying a contract with constructor arguments, make sure you match them exactly as they were deployed, including any addresses, uints, or strings.

Useful MST Blockchain Info
 

NetworkChain IDRPC URLsCoinBlock ExplorerMST Mainnet4646https://mariorpc.mstblockchain.com
https://craftrpc.mstblockchain.comMSTCmstscan.comMST Testnet4545https://testnetrpc.mstblockchain.comtMSTCtestnet.mstscan.com

Next Steps 

  • Interact with your deployed contract via Hardhat scripts or Ethers.js

  • Verify the contract source code on MSTScan

  • Build your dApp on top of MST Blockchain

Final Words

Deploying on MST Blockchain is fast and developer-friendly, thanks to its EVM compatibility and high performance. MST is ready for your smart contracts!

If you face any issues or want to stay updated, follow MST Blockchain community and developer channels.

Happy BUIDLing!

 Frequently Asked Question

1. How do you deploy a smart contract on MST Blockchain?

To deploy a smart contract on MST Blockchain, write the contract in Solidity, compile it using a compatible development tool, connect to the correct network, and confirm the deployment transaction.

2. Which programming language is used for smart contract development?

Solidity is a widely used programming language for developing smart contracts on Ethereum-compatible blockchain networks.

3. What tools are needed to deploy a smart contract?

Developers commonly use Remix IDE or Hardhat, a compatible crypto wallet, the target blockchain's RPC endpoint, and sufficient native tokens to pay transaction fees.

4. How much does it cost to deploy a smart contract on MST Blockchain?

The deployment cost depends on the contract's complexity, gas consumption, and network fees. Check the current network conditions to estimate the transaction cost.

5. How can you verify a smart contract after deployment?

You can check the deployment transaction and contract address using the official blockchain explorer, if available. Source-code verification may also be supported.