Using Hardhat
Last updated
Last updated
There are a few technical requirements before we start. Please install the following:
(comes with Node)
Once we have those installed, To install Hardhat, you need to create an npm project by going to an empty folder, running npm init, and following its instructions. Once your project is ready, you should run
Copy
To create your Hardhat project run npx hardhat
in your project folder Let’s create the sample project and go through these steps to try out the sample task and compile, test and deploy the sample contract.
The sample project will ask you to install hardhat-waffle and hardhat-ethers.You can learn more about it
Go to hardhat.config.js
Update the hardhat-config with CTEX-network-credentials
Create .env file in the root to store your private key
Add CTEXscan API key to .env file to verify the contract on CTEXscan. You can generate an API key by
Copy
Make sure to update the Solidity compiler version here based on what is required in your contract(s).
Copy
Run this command in root of the project directory:
Copy
Contract will be deployed on CTEX Chain Testnet, it look like this:
Copy
Remember your address would differ, Above is just to provide an idea of structure. Congratulations! You have successfully deployed Smart Contract. Now you can interact with the Smart Contract.
Copy
Remember to update your address to your own deployed contract address. When the command is successful, you will see your contract verified on ctexscan!
You can check the deployment status here:
Run the following commands to quickly verify your contract on ctexscan. This makes it easy for anyone to see the source code of your deployed contract. For contracts that have a constructor with a complex argument list, see .