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:
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 buildyarn hardhat buildpnpm exec hardhat buildbun x hardhat buildCheck 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.jsonMultiple Compiler Versions
If you have contracts requiring different Solidity versions:
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 buildyarn hardhat clean
yarn hardhat buildpnpm exec hardhat clean
pnpm exec hardhat buildbun x hardhat clean
bun x hardhat build