Code Monkey home page Code Monkey logo

hardhat-example's Introduction

hardhat-example

hardhat-example provides a simple smart contract deployment framework using the Hardhat development kit on Quai Network.

This project demonstrates a basic Hardhat use case. It comes with a few sample contracts, and a script that deploys a contract.

Dependencies

Run and Deploy

Install Dependencies

  1. Clone hardhat-example
git clone https://github.com/dominant-strategies/hardhat-example
  1. 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 to add path to your solc binary into the customCompilerPath variable in the hardhat.config.js file. The file already includes common paths for MacOS and Linux as comments.

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.

Deploying a Simple Contract

  1. The deploy.js script is configured to deploy the greeter.sol contract by default.
    • Pass the name of the greeter contract into the hardhat runtime contract definition
    • Pass the initial greeting constructor argument into the deploy command
  2. Compile greeter contract using npx hardhat compile
  3. Deploy greeter to a single chain using npx hardhat run scripts/deploy.js
    • This will deploy to the defaultNetwork specified in your hardhat.config.js
    • You can specify a network other than the defaultNetwork by passing the --network networkName flag to the deploy command. Replace networkName with one of the options below.
    • Available networkName are:
      • cyprus1
      • cyprus2
      • cyprus3
      • paxos1
      • paxos2
      • paxos3
      • hydra1
      • hydra2
      • hydra3

Deploying QRC20 or QRC721

The deployQRC20.js and deployQRC721.js scripts have been included as a simple method of deploying QRC20 and QRC721 contracts to a single chain within Quai Network.

To specify token details (token name, ticker, supply, etc) for either the QRC20 or QRC721 contract, modify the constructorArgs object in the deploy script. Then compile the contract via npx hardhat compile and deploy via npx hardhat run scripts/deployQRC20.js or npx hardhat run scripts/deployQRC721.js.

Hardhat

Hardhat has a number of other useful CLI commands.

npx hardhat compile
npx hardhat clean
npx hardhat test
npx hardhat help

Authors

Juuddi

hardhat-example's People

Contributors

juuddi avatar alanorwick avatar veronikapolar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.