Caduceus

⌘K
Quickstart
Blockchain Basics
What is a Blockchain?
Types of Blockchain
Consensus Mechanism
What is a Smart Contract?
The Ethereum Virtual Machine
Solidity
Caduceus Basics
What is Caduceus?
Consensus
Parallel Execution
Storage
Edge Rendering
Smart Contracts
Nodes
Tokenomics
GameFi
Introduction to GameFi
Introduction to Unity
ChainSafe SDK overview
Using ChainSafe with Unity
Users
Wallets
Exchanges
D'Apps
🦉Oracles
Redstone
Developers
To Api's
Caduceus RPC Endpoints
Getting Testnet Tokens
SDK's
Templates
Tutorials
EVM Tools
Explorers
XR Dev Kit
Node Operators
Node Architecture
Network Specs
Running a V1 Node
Staking
Feedback
Docs powered by archbee 
8min

Connecting Hardhat to Caduceus

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
|
# clone the repository
git clone https://github.com/OpenZeppelin/openzeppelin-contracts.git
# enter into the directory
cd openzeppelin-contracts
# installs packages
yarn


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
|
module.exports = {
    networks: {
        hardhat: {
            blockGasLimit: 10000000,
            allowUnlimitedContractSize: !withOptimizations,
        },
    },
},


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
|
module.exports = {
    networks: {
        hardhat: {
            blockGasLimit: 10000000,
            allowUnlimitedContractSize: !withOptimizations,
        },
        caduceusTestnet: {
            url: 'https://galaxy.block.caduceus.foundation',
            accounts: {
                mnemonic: 'test test test test test test test test test test test test',
                path: "m/44'/60'/0'/0",
                initialIndex: 0,
                count: 20,
                passphrase: '',
            },
        },
    },
},


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

Click here to learn more about hardhat configuration and networks



Running tests

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

Shell
|
npx hardhat test ./test/finance/VestingWallet.test.js --network caduceusTestnet


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 03 Mar 2023
Did this page help you?
Yes
No
UP NEXT
Explorers
Docs powered by archbee 
TABLE OF CONTENTS
Forking a Hardhat Project
Changing the Config
Running tests