PBM Solidity implementation
PBM Solidity implementation
Description
We provide a list of sample PBM implementation for reference.
Provided Contracts and Tests
contracts/preloaded-pbm/XXXX.sol
- PBMRC1 implementation contract to demonstrate preloaded PBMscontracts/non-preloaded-pbm/XXXX.sol
- Interface contractcontracts/XXXX.sol
- Interface contractcontracts/ERC20.sol
- ERC20 token contract for unit teststest/XXXXX.js
- Unit tests for livecycle of the PBM implementation
Used javascript based testing libraries for solidity
hardhat
: hardhat allows for testing of contracts with JavaScript via Mocha as the test runnerchai
: Chai is an assertion library and provides functions like expect.ethers
: This is a popular Ethereum client library. It allows you to interface with blockchains that implement the Ethereum API.
Compile and run tests with hardhat
We provide the essential steps to compile the contracts and run provided unit tests
Check that you have the latest version of npm and node via npm -version
and node -v
(should be a LTS version for hardhat support)
- Check out project
- Go to folder and initialise a new npm project:
npm init -y
. A basicpackage.json
file should occur - Install Hardhat as local solidity dev environment:
npx hardhat
- Select following option: Create an empty hardhat.config.js
- Install Hardhat as a development dependency:
npm install --save-dev hardhat
- Install further testing dependencies:
npm install --save-dev @nomiclabs/hardhat-waffle @nomiclabs/hardhat-ethers ethereum-waffle chai ethers solidity-coverage
- Install open zeppelin contracts:
npm install @openzeppelin/contracts
- add plugins to hardhat.config.ts:
require("@nomiclabs/hardhat-waffle");
require('solidity-coverage');
- Adding commands to
package.json
:
"scripts": {
"build": "hardhat compile",
"test:light": "hardhat test",
"test": "hardhat coverage"
},
- run
npm run build
- run
npm run test