Lean Hardhat starter for compiling, testing, deploying, verifying, and interacting with EVM smart contracts on Injective Testnet.
Stack: Hardhat · Solidity · Ethers · Blockscout · Injective EVM
Use this repository as a template.
- On GitHub, press the "Use this template" button.
- In the dropdown, select "Create new repository"
- Fill in the form, then press the "Create repository"
- You should now have a copy of the template repo in your own Github account or organisation
- Click on the "<> Code" button
- In the dropdown, select the "Local" tab, then copy the git URL
Install dependencies and configure your environment:
git clone https://github.com/${YOUR_GITHUB}/hardhat-injective-template.git hardhat-injective-template
cd hardhat-injective-template
npm install
cp .env.example .envUpdate .env with your Injective testnet RPC URL and a funded private key.
(See "Configuration" section below.)
Run:
npm run compile # compile contract
npm run test # run local (simulated EVM) tests
npm run deploy # deploy contract to Injective Testnet
npm run verify -- 0xYOURADDRESS # verify deployed contract on Injective Testnet Blockscout
npm run interact # open a Hardhat console on Injective Testnet to
# query/transact with deployed contract- Hardhat project structure: Minimal layout for contracts, tests, scripts, and config.
- Injective testnet config: Ready-to-use
inj_testnetnetwork inhardhat.config.js. - Blockscout verification config: Pre-wired
hardhat verifysupport for Injective Testnet. - Environment-based secrets: JSON-RPC URL and deployer private key in
.env.
-
contracts/Counter.sol: Tiny example contract to confirm the toolchain works. -
test/Counter.test.js: Local test coverage for the included contract. -
script/deploy.js: Deployment script for Injective Testnet.
├── contracts/
│ └── Counter.sol # Minimal starter contract
├── script/
│ └── deploy.js # Deploys Counter to Injective Testnet
├── test/
│ └── Counter.test.js # Local contract tests
├── .env.example # Environment variable template
├── .gitignore
├── hardhat.config.js # Hardhat + Injective + Blockscout config
├── package.json
└── README.md
Copy .env.example to .env and provide:
INJ_TESTNET_RPC_URL=https://k8s.testnet.json-rpc.injective.network/
PRIVATE_KEY=your_private_key_without_0x_prefixPRIVATE_KEY is optional for local compilation and testing, but required for:
npm run deploy, npm run verify, and npm run console.
Obtain this from your wallet.
Fund your wallet using testnet.faucet.injective.network.
The included deploy script uses Injective-friendly defaults:
gasPrice:160000000gasLimit:2000000
MIT