/AUPP-CODE-C

Primary LanguageTypeScript

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