Developers
...
EVM Tools
HardHat

Connecting Hardhat to Caduceus

6min

Forking a Hardhat Project

We recommend you create a clone a repository like https://github.com/OpenZeppelin/openzeppelin-contracts which already has Hardhat set up and working. It also comes with an extensive amount of expertly written smart contracts which can be used to bootstrap your development. So fork the repository and go through the readme to get you up and running

Shell


alternatively you can also do this hardhat tutorial to initialise a new project: https://hardhat.org/hardhat-runner/docs/getting-started#quick-start

Changing the Config

Inside your hardhat.config.js there will be a networks object. this object is where you can define other networks for hardhat to deploy and test the smart contracts on. This means you can point hardhat to the Testnet.

note that the hardhat network is the default network used.

hardhat.config.js


To add the caduceus network you have to add the RPC endpoint along with a test wallet that ideally has Test CMP tokens. As deploying and interacting with contracts will take up CMP for gas.

hardhat.config.js


As you can see the url is set to our testnet RPC endpoint. Also there is an accounts object which includes the wallets Secret Recovery Phrase along with other path details. These path details are the default path details for HD wallets thus they might work for your wallet as well.

If you use MetaMask you can copy your mnemonic phrase from the app and paste it in here with this config and it should work.

Go to here to see how to get your mnemonic phrase from MetaMask - Create a Wallet



Running tests

Now your hardhat configuration is set up you can execute tests by doing

Shell


where the --network flag is the key of the of the network object in the config file. In our case we named it caduceusTestnet.

When you decide to run tests that deploy and interact with contracts then make sure that each account has enough CMP tokens to do so. Getting Testnet Tokens can help you get test CMP.



Updated 25 Mar 2024
Doc contributor
Did this page help you?