Skip to content

Latest commit

 

History

History
123 lines (83 loc) · 5.36 KB

README.md

File metadata and controls

123 lines (83 loc) · 5.36 KB

SolidityX

The SolidityX folder of hardhat-example provides an example hardhat configuration for deploying SolidityX based contracts to Quai Network.

Dependencies

Run and Deploy

Install Dependencies

Before installing dependencies, make sure you're inside of the SolidityX directory.

Install package dependencies

npm i

Local SolidityX Compiler

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

Installing via Plugin

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.

Installing from Source

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.

Environment Config

  • 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
    • RPC Endpoints
      • RPC endpoints are default configured for a local node.
      • Local: HTTP ports for each chain's RPCURL can be found here.
      • Remote: hosted RPC endpoints for each chain can be found here.

Configure and Deploy QRC20 and QRC721 Tokens

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.

QRC20 configuration

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.

QRC721 configuration

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.

Deploy

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

Verify Contract

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.