Once your environment is ready, we can create an empty folder and init a Hardhat project in it.
$mkdirmy-thundercore-project&&cd $_# We choose a basic sample project and install its dependences here:$npxhardhatinit✔Whatdoyouwanttodo?·Createabasicsampleproject✔Doyouwanttoinstallthissampleproject's dependencies with npm (hardhat @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers ethers)? (Y/n) · y
After initialization, we can test the project with the hardhat compile command:
Never store your private key directly in hardhat.config.js
Here we pass the its value on the command line or store it in `.env`.
Deploy to ThunderCore Network
Let's deploy the first contract.
You'll need some gas tokens to deploy contracts. To test on ThunderCore testnet, you can get some testnet tokens from ThunderCore testnet Faucet
# Using NPMKEY=0xPrivateKeynpmexec--hardhatrunscripts/sample-script.js--networkthunder-testnet# or using YarnKEY=0xPrivateKeyyarnhardhatrunscripts/sample-script.js--networkthunder-testnet
# Using NPMsetKEY=0xPrivateKey&npmexec--hardhatrunscripts/sample-script.js--networkthunder-testnet# or using YarnsetKEY=0xPrivateKey&yarnhardhatrunscripts/sample-script.js--networkthunder-testnet
# Using NPM$env:KEY='0xPrivateKey';npmexec--hardhatrunscripts/sample-script.js--networkthunder-testnet# or using Yarn$env:KEY='0xPrivateKey';yarnhardhatrunscripts/sample-script.js--networkthunder-testnet
By using the tt-hardhat plugin, you can import logDeployContracts from hardhat to log your deployed contracts. More info
Congratulations! You have successfully deployed a smart contract onto the ThunderCore network, you will find the deployed messages look like:
Greeter deployed to: 0xGreeterContractAddress
Verify contract by plugin
Once you deployed your contract, you might want to verify your contract code.
On ThunderCore testnet, we provide Blockscout as our block explorer. You can use hardhat-etherscan plugin to verify your contract.
yarnadd-D@nomiclabs/hardhat-etherscan
after installed the package, modify your hardhat.config.js