RISE Logo-Light

Compiling Contracts

Compile smart contracts with Hardhat for RISE

Compile your Solidity contracts to bytecode and ABI for deployment on RISE.

Configuration

Ensure your hardhat.config.ts has the Solidity compiler configured:

hardhat.config.ts
import "dotenv/config";
import { defineConfig } from "hardhat/config";
import hardhatToolboxMochaEthers from "@nomicfoundation/hardhat-toolbox-mocha-ethers";

export default defineConfig({
  plugins: [hardhatToolboxMochaEthers],
  solidity: {
    version: "0.8.30",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  },
  networks: {
    rise: {
      type: "http",
      url: process.env.RISE_RPC_URL || "https://testnet.riselabs.xyz",
      accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
      chainId: 11155931
    }
  }
});

Compile

Run Build

Compile all contracts in the contracts/ directory:

npx hardhat build
yarn hardhat build
pnpm exec hardhat build
bun x hardhat build

Check Artifacts

Compilation generates artifacts in the artifacts/ directory containing:

  • Contract ABI
  • Bytecode
  • Source maps for debugging

The compiled JSON files can be found at:

artifacts/contracts/YourContract.sol/YourContract.json

Multiple Compiler Versions

If you have contracts requiring different Solidity versions:

hardhat.config.ts
export default defineConfig({
  solidity: {
    compilers: [
      { version: "0.8.30" },
      { version: "0.7.6" }
    ]
  }
});

Clean and Recompile

To force a fresh compilation:

npx hardhat clean
npx hardhat build
yarn hardhat clean
yarn hardhat build
pnpm exec hardhat clean
pnpm exec hardhat build
bun x hardhat clean
bun x hardhat build

Next Steps