Solidity Compiler Compatibility on MST Blockchain

What Every Developer Needs to Know Before Deploying Smart Contracts on MST Blockchain

By Prakhar SharmaDeveloper Docs
Solidity Compiler Compatibility on MST Blockchain

What Every Developer Needs to Know

If you've been deploying smart contracts on MST blockchain and run into cryptic compilation errors or unexpected reverts, there's a good chance your toolchain is silently compiling against a Solidity version your target network doesn't support. This guide explains why that happens and exactly how to fix it.

The Two Networks, and Where They Stand

MST blockchain runs two environments: Mainnet and Testnet. They don't share the same EVM capabilities, and that asymmetry is the root cause of most compiler-related headaches.

Mainnet Testnet EVM Version Paris Cancun Upcoming Upgrade → Cancun (soon) Already upgraded Supports latest Solidity? No Partial

Mainnet Paris EVM

Mainnet currently runs on the Paris EVM hardfork. This means any opcode or feature introduced after Paris such as PUSH0 (Shanghai) or TLOAD/TSTORE (Cancun) — is not available. Contracts compiled targeting these newer EVMs will fail to deploy or behave unexpectedly on mainnet.

Mainnet will be upgraded to Cancun in the near future, but until that happens, you must compile targeting Paris.

Testnet Cancun EVM

Testnet has already been upgraded to support the Cancun EVM hardfork. This unlocks transient storage (TLOAD/TSTORE), blob-carrying transactions (EIP-4844 primitives), and other Cancun-era features.

However, testnet does not support the most recent Solidity versions released after Cancun. Bleeding-edge compiler versions may introduce new opcodes or language features the testnet EVM doesn't yet recognise.

Why Your Framework Is Using the Wrong Compiler

Both Foundry and Hardhat default to the latest available Solidity compiler. This is great for greenfield projects targeting cutting-edge networks, but it becomes a problem when:

  • You're deploying to mainnet (Paris), and the latest solc targets Shanghai or Cancun opcodes.

  • You're deploying to testnet (Cancun), and the latest solc uses post-Cancun features not yet recognised by the EVM.

The result is usually one of these failure modes:

  • Invalid Opcode revert at runtime (compiled opcode not recognised by the EVM)

  • Evm Version Mismatch errors during deployment

  • Subtle bugs from opcodes silently falling back to unintended behaviour

The fix is straightforward: pin the EVM target and the Solidity version in your project configuration.

Recommended Compiler Versions

Target Network EVM Version Recommended Solidity Mainnet (current) paris ^0.8.20 Mainnet (post-upgrade) cancun ^0.8.24 Testnet cancun ^0.8.24 Avoid on either network — >= 0.8.25 (until confirmed)

Note: Avoid using ^0.8.25 or later on testnet until those versions are explicitly confirmed as supported. When in doubt, use 0.8.24.

Fixing It in Foundry

Foundry is configured via foundry.toml at the root of your project.

For Mainnet (Paris EVM)

# foundry.toml
[profile.default]
solc = "0.8.20"
evm_version = "paris"

For Testnet (Cancun EVM)

# foundry.toml
[profile.default]
solc = "0.8.24"
evm_version = "cancun"

Using Profiles to Handle Both Networks

Foundry's profile system lets you define separate configs and switch between them with an environment variable.

# foundry.toml
[profile.default]
solc = "0.8.20"
evm_version = "paris"
[profile.testnet]
solc = "0.8.24"
evm_version = "cancun"

Then activate the testnet profile when needed:

# Deploy or test against testnet
FOUNDRY_PROFILE=testnet forge build
FOUNDRY_PROFILE=testnet forge test
FOUNDRY_PROFILE=testnet forge script script/Deploy.s.sol \
  --rpc-url $TESTNET_RPC_URL --broadcast

Omitting FOUNDRY_PROFILE always falls back to [profile.default] — which you should keep pointing at mainnet (Paris) for safety.

Verifying Your Build Target

forge build --force 2>&1 | grep 'Compiler'# Expected: Compiling X files with 0.8.20 (or 0.8.24)

Fixing It in Hardhat

Hardhat is configured in hardhat.config.js (or hardhat.config.ts for TypeScript).

For Mainnet (Paris EVM)

// hardhat.config.jsrequire("@nomicfoundation/hardhat-toolbox");
/** @type import("hardhat/config").HardhatUserConfig */
module.exports = {
  solidity: {
    version: "0.8.20",
    settings: {
      evmVersion: "paris",
      optimizer: {
        enabled: true,
        runs: 200,
      },
    },
  },
};

For Testnet (Cancun EVM)

// hardhat.config.jsrequire("@nomicfoundation/hardhat-toolbox");
module.exports = {
  solidity: {
    version: "0.8.24",
    settings: {
      evmVersion: "cancun",
      optimizer: {
        enabled: true,
        runs: 200,
      },
    },
  },
};

TypeScript Config

// hardhat.config.tsimport { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
const config: HardhatUserConfig = {
  solidity: {
    version: "0.8.24",
    settings: {
      evmVersion: "cancun",   // or "paris" for mainnet
      optimizer: {
        enabled: true,
        runs: 200,
      },
    },
  },
};
export default config;

Supporting Multiple Solidity Versions

If your project has contracts that need different versions (e.g. third-party dependencies with a different pragma), use the compilers array:

// hardhat.config.js
module.exports = {
  solidity: {
    compilers: [
      {
        version: "0.8.24",       // Your contracts (testnet)
        settings: {
          evmVersion: "cancun",
          optimizer: { enabled: true, runs: 200 },
        },
      },
      {
        version: "0.8.20",       // Legacy dependency contracts
        settings: {
          evmVersion: "paris",
          optimizer: { enabled: true, runs: 200 },
        },
      },
    ],
  },
};

Environment-Aware Config

A clean pattern for keeping mainnet and testnet configs in one file:

// hardhat.config.jsconst isTestnet = process.env.NETWORK === "testnet";
module.exports = {
  solidity: {
    version: isTestnet ? "0.8.24" : "0.8.20",
    settings: {
      evmVersion: isTestnet ? "cancun" : "paris",
      optimizer: { enabled: true, runs: 200 },
    },
  },
  networks: {
    mainnet: {
      url: process.env.MAINNET_RPC_URL || "",
      accounts: [process.env.PRIVATE_KEY],
    },
    testnet: {
      url: process.env.TESTNET_RPC_URL || "",
      accounts: [process.env.PRIVATE_KEY],
    },
  },
};

Then deploy with:

# Testnet
NETWORK=testnet npx hardhat run scripts/deploy.js --network testnet
# Mainnet
npx hardhat run scripts/deploy.js --network mainnet

Also Pin the Version in Your Contract Pragma

Beyond your build tool config, it's good practice to be explicit in your Solidity source files too. Avoid open-ended pragmas like pragma solidity ^0.8.0; these allow the compiler to pick any version and can mask version drift.

// Good — explicit upper boundpragma solidity ^0.8.20;   // mainnetpragma solidity ^0.8.24;   // testnet// Avoid — too permissivepragma solidity >=0.8.0;pragma solidity ^0.8.0;

Pre-Deploy Checklist

Before deploying to either network, run through this:

  • ✓foundry.toml or hardhat.config.js has the correct solc/version set

  • ✓evm_version / evmVersion matches your target network (paris or cancun)

  • ✓Your contract pragma is explicitly pinned, not open-ended

  • ✓You've run a fresh forge build --force or npx hardhat compile --force after any config change

  • ✓You're not using Cancun-only features (TLOAD, TSTORE, blobhash) in contracts destined for mainnet until the upgrade lands

After the Mainnet Cancun Upgrade

Once mainnet upgrades to Cancun, you can consolidate your configs:

  • Both networks will share the same EVM target (cancun)

  • You can safely move to solc 0.8.24 across the board for all deployments

  • Watch the official MST announcements for the exact upgrade date — until then, keep mainnet builds targeting paris

Summary

Scenario EVM Version Solidity Version Deploying to Mainnet today paris 0.8.20 Deploying to Testnet today cancun 0.8.24 After Mainnet Cancun upgrade cancun 0.8.24 Avoid on either network — >= 0.8.25 (until confirmed)

Pinning your compiler version takes two lines of config, but it saves you from silent failures, unexpected reverts, and hours of debugging gas estimation errors. Set it once per environment, commit it to your repo, and move on.

Stay connected with MST Blockchain

Follow the journey and join India's fastest-growing Web3 community:

Website  |  Telegram  |  X (Twitter)  |  LinkedIn

Frequently Asked Questions

1. What is Solidity compiler compatibility?

Solidity compiler compatibility means ensuring your compiler version works with your smart contract code and target blockchain.

2. Which Solidity compiler version should I use on MST Blockchain?

Use a Solidity compiler version supported by MST Blockchain’s development environment and compatible with your smart contract dependencies.

3. How do I check Solidity compiler compatibility?

Check your contract’s pragma solidity statement, compiler version, dependencies, and target EVM settings before deployment.

4. Can I deploy Solidity smart contracts on MST Blockchain?

If your contract uses supported EVM-compatible features, you can deploy it using compatible development tools and network settings.

5. Why does Solidity compiler version matter?

The compiler version affects syntax support, bytecode generation, security fixes, and smart contract deployment compatibility.