The SolidityX
folder of hardhat-example
provides an example hardhat configuration for deploying SolidityX based contracts to Quai Network.
- Hardhat: Development toolkit
- SolidityX: A fork of the Solidity compiler that supports Quai Network's QRC20 and QRC721 token standards
- Nodejs: Javascript runtime engine
@nomicfoundation/hardhat-toolbox
: Hardhat utilsquais
andquais-polling
: Javascript SDK for interacting with Quai Networkquai-hardhat-plugin
: A plugin that installs the SolidityX compiler for use with Hardhat.dotenv
: A zero-dependency module that securely loads environment variables.
Before installing dependencies, make sure you're inside of the SolidityX
directory.
Install package dependencies
npm i
There are two methods of installing the SolidityX compiler for use with Hardhat:
- Install the SolidityX compiler via
quai-hardhat-plugin
(Recommended) - Install and build the SolidityX compiler from source
If you've installed quai-hardhat-plugin
already, the SolidityX compiler will be installed automatically when you run npx hardhat compile
for MacOS and Linux users. Windows is not currently supported by the plugin.
Note: Building the compiler from source still requires the quai-hardhat-plugin
to be installed.
Visit the SolidityX Repository for instructions on how to clone and build the SolidityX compiler for your specific operating system.
Once you've built the SolidityX compiler, you'll need move the resultant solc
inside of the SolidityX
directory so that hardhat
can find it.
- 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: deployQRC20.js
and deployQRC721.js
. These scripts will grab your deployment configurations in tandem with a network flag passed to the deploy command to automatically deploy your QRC20 or QRC721 contract to the network of your choice.
Open the deployQRC20.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/deployQRC20.js
.
Open the deployQRC721.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/deployQRC721.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 QRC20 to paxos2
npx hardhat run scripts/deployQRC20.js --network paxos2
# Deploy QRC721 to hydra1
npx hardhat run scripts/deployQRC721.js --network hydra1
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 QRC20
npx hardhat verify --constructor-args "arguments/argumentQRC20.js" --contract "contracts/QRC20.sol:QRC20" --network paxos2 DEPLOYED_CONTRACT_ADDRESS
# Verify QRC721
npx hardhat verify --constructor-args "arguments/argumentQRC721.js" --contract "contracts/QR721.sol:QRC721" --network paxos2 DEPLOYED_CONTRACT_ADDRESS
Replace DEPLOYED_CONTRACT_ADDRESS
with contract address you got from the deployment process.