The Solidity
folder of hardhat-example
provides an example hardhat configuration for deploying Solidity based contracts to Quai Network.
- Hardhat: Development toolkit
- Nodejs: Javascript runtime engine
@nomicfoundation/hardhat-toolbox
: Hardhat utilsquais
andquais-polling
: Javascript SDK for interacting with Quai Networkdotenv
: A zero-dependency module that securely loads environment variables.
Before installing dependencies, make sure you're inside of the Solidity
directory.
Install package dependencies
npm i
- Copy
../.env.dist
to../.env
.
cp ../.env.dist ../.env
- Define network variables inside of the
.env
file.- Private Keys
- The sample environment file is configured with a placeholder private key for each chain.
- Replace the placeholder private key for each chain with your own private key that corresponds to the address you want to deploy from.
- You cannot use the same private key for each chain.
- Chain ID
- Depending on the network you're deploying to, you'll need to set the
CHAINID
variable to the correct chain ID.- Local:
1337
- Testnet:
9000
- Devnet:
12000
- Local:
- Depending on the network you're deploying to, you'll need to set the
- RPC Endpoints
- Private Keys
This repo has two pre-configured deployment scripts: deployERC20.js
and deployERC721.js
. These scripts will grab your deployment configurations in tandem with a network flag passed to the deploy command to automatically deploy your ERC20 or ERC721 contract to the network of your choice.
Open the deployERC20.js
file and modify the constructorArgs
object to specify the token details (token name, ticker, supply, etc). Then compile the contract via npx hardhat compile
and deploy via npx hardhat run scripts/deployERC20.js
.
Open the deployERC721.js
file and modify the constructorArgs
object to specify the token details (token name, ticker, baseURI, etc). Then compile the contract via npx hardhat compile
and deploy via npx hardhat run scripts/deployERC721.js
.
After configuring your deployment scripts, you'll need to compile the contracts.
npx hardhat compile
Depending on the contract you want to deploy, run the respective deployment script:
# Deploy ERC20 to paxos1
npx hardhat run scripts/deployERC20.js --network paxos1
# Deploy ERC721 to hydra2
npx hardhat run scripts/deployERC721.js --network hydra2
To deploy to a specific network, pass the --network networkName
flag to the deploy command. Replace networkName
with one of the options below. If you don't pass a network flag, the contract will be deployed to the defaultNetwork
specified in your hardhat.config.js
.
cyprus1
cyprus2
cyprus3
paxos1
paxos2
paxos3
hydra1
hydra2
hydra3
After the contract is deployed, you can verify the deployed contract using the command
# Verify ERC20
npx hardhat verify --constructor-args "arguments/argumentERC20.js" --contract "contracts/ERC20.sol:ERC20" --network paxos2 DEPLOYED_CONTRACT_ADDRESS
# Verify ERC721
npx hardhat verify --constructor-args "arguments/argumentERC721.js" --contract "contracts/ER721.sol:ERC721" --network paxos2 DEPLOYED_CONTRACT_ADDRESS
Replace DEPLOYED_CONTRACT_ADDRESS
with contract address you got from the deployment process.