GithubHelp home page GithubHelp logo

basic-template-from-bscp's Introduction

BSCP

Basic Smart Contract Project(BSCP) template

codecov

This template using a basic Hardhat, mocha test, typechain. It comes with a sample contract, a test for that contract, and a script that deploys that contract.

How dose it make from?

Using Yarn Berry:

yarn init -2
    ...
yarn config set nodeLinker node-modules
yarn add hardhat --dev
yarn hardhat init
    "Create a TypeScript project"
    ...
    .gitignore? Y
yarn add --dev [list of suggested dev dependencies above]
yarn add mocha --dev

Recommended extensions

Git Graph

Mocha Test Explorer

Solidity

Environment setup

.mocharc.json file:

{
  "require": "hardhat/register",
  "timeout": 40000,
  "_": ["tests/**/*.ts"]
}
Suggested renaming:
// Renaming "test" folder
mv test tests
If using Yarn Berry with PnP:
// Setting up yarn sdk for vscode
yarn dlx @yarnpkg/sdks vscode
// Press ctrl+shift+p in a TypeScript file
// Choose "Select TypeScript Version"
// Pick "Use Workspace Version"

hardhat.config.ts file:

{
const config: HardhatUserConfig = {
...
  paths: { tests: "tests" },
...
  }
}

tsconfig.json file:


...
  "include": ["./scripts", "./tests", "./typechain"],
  "files": ["./hardhat.config.ts"],
...

Create env file in root project folder

.env file:

MNEMONIC="here is where your twelve words mnemonic should be put my friend"
PRIVATE_KEY="<your private key here if you don't have a mnemonic seed>"
INFURA_API_KEY="********************************"
INFURA_API_SECRET="********************************"
ALCHEMY_API_KEY="********************************"
ETHERSCAN_API_KEY="********************************"

Edit the environment with your keys:

code .env

Test it out:

 yarn hardhat compile 
 yarn hardhat test 

Accounts task:

task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
  const accounts = await hre.ethers.getSigners();
  for (const account of accounts) {
    console.log(account.address);
  }
});

Test it out:

 yarn hardhat accounts 

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.