Coder Social home page Coder Social logo

hardhat-reef-examples's Introduction

hardhat-reef-examples

hardhat-reef-examples shows the use of hardhat-reef plugin to interact with the Reef chain.

Installing

Install dependencies with yarn.

Running

Define your Reef chain URL in hardhat.config.js (by default ws://127.0.0.1:9944):

module.exports = {
  solidity: "0.7.3",
  defaultNetwork: "reef",
  networks: {
    reef: {
      url: "ws://127.0.0.1:9944",
    },
    reef_testnet: {
      url: "wss://rpc-testnet.reefscan.com/ws",
      scanUrl: "https://testnet.reefscan.com", // Localhost verification testing: http://localhost:3000
      seeds: {
        testnet_account: "<MNEMONIC_SEED>",
      },
    },
    reef_mainnet: {
      url: "wss://rpc.reefscan.com/ws",
      scanUrl: "wss://reefscan.com",
      seeds: {
        mainnet_account: "<MNEMONIC_SEED>",
      },
    },
  },
};

Copy .env.example to .env (cp .env.example .env) and update the desired mnemonic variable to your account seed mnemonic for the corresponding network.

You can have multiple accounts by listing them in dictionary with your custom name:

seeds: {
	account1: "<MNEMONIC_SEED1>",
	account2: "<MNEMONIC_SEED2>",
	...
},

In JS script you can select the account with:

const reef = await hre.reef.getSignerByName("account1");

where account1 is the key of the item in the seeds dictionary.

If you get the following error:

Invalid Transaction: Inability to pay some fees , e.g. account balance too low

it is most likely because the accounts defined in the hardhat.config.js and JS script do not match.

Scripts

See scripts/ folder for example scripts, e.g. to deploy flipper run:

yarn hardhat run scripts/flipper/deploy.js 

After the contract is deployed, you can interact with it using the flip.js script:

yarn hardhat run scripts/flipper/flip.js 

make sure the flipperAddress corresponds to the deployed address.

Deploy and verify Token contract:

yarn hardhat run scripts/erc20/deploy_and_verify.js --network reef_testnet

Integration localhost tests with reef-explorer

yarn hardhat run scripts/integration-test.js

Deploying on testnet

The above commands will deploy on development (local) network by default. To deploy on testnet, use the --network flag:

yarn hardhat run scripts/flipper/deploy.js --network reef_testnet 

To get initial REEF tokens on the testnet, visit dev Matrix chat and use the following command:

!drip REEF_ADDRESS

hardhat-reef-examples's People

Contributors

jbargu avatar frenkiee avatar frisitano avatar netherdrake avatar samuelalev 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.