This project demonstrates how to compile, deploy, and interact with smart contracts on the Core using Hardhat. It supports both Core Mainnet, and Core Testnet.
✅ Recommended for developers building and testing smart contracts on Core.
- Multi-network support (Core Mainnet, Testnet2)
- Configurable Solidity compiler versions and EVM settings
- Integration with block explorers for contract verification
- Optimized for performance with Hardhat’s toolbox
- Structured project setup with support for scripts and testing
❗ Note: Hardhat Ignition is currently not compatible with Core Blockchain.
Use custom deployment scripts (scripts/deploy.js
) instead.
git clone https://github.com/coredao-org/hardhat-tutorial.git
cd hardhat-tutorial
npm install
Create a .env
file in the project root and add the following variables:
PRIVATEKEY="your_core_wallet_private_key"
CORE_MAIN_SCAN_KEY="your_mainnet_explorer_api_key"
CORE_TEST2_SCAN_KEY="your_testnet2_explorer_api_key"
⚠️ Important: Never share your private key or commit the.env
file to version control.
npx hardhat compile
npx hardhat test
Use a deployment script instead of Hardhat Ignition.
npx hardhat run scripts/deploy.js --network <network_name>
Replace <network_name>
with one of:
core_mainnet
core_testnet2
Example:
npx hardhat run scripts/deploy.js --network core_testnet2
The project is configured to support multiple Core environments:
- Testnet2 & Mainnet:
- Solidity version:
0.8.24
- EVM version:
Shanghai
- Solidity version:
All networks are pre-configured in hardhat.config.js
:
networks: {
core_mainnet: {
url: "https://rpc.coredao.org/",
accounts: [process.env.PRIVATEKEY],
chainId: 1116,
},
core_testnet2: {
url: "https://rpc.test2.btcs.network",
accounts: [process.env.PRIVATEKEY],
chainId: 1114,
},
}
Supports contract verification via Core block explorers.
Example command:
npx hardhat verify --network core_testnet2 <deployed_contract_address> <constructor_args_if_any>
API keys for verification should be placed in your .env
file.
⚠️ hardhat-ignition
is not supported for Core Blockchain.
To deploy contracts, always use a custom deployment script like:
// scripts/deploy.js
This ensures compatibility with Core's RPC structure and avoids issues during deployment.
This project is intended for educational and development use only. Always safeguard your private keys and never expose sensitive credentials in your codebase or version control.