forked from DecentralizedClimateFoundation/DCIPs
2.1 KiB
2.1 KiB
SDC Solidity implementation
Description
This sdc implementation aims to implement process logic in a very lean way using an integrative solidity implementation and according unit tests
Provided Contracts and Tests
contracts/ISDC.sol
- Interface contractcontracts/SDC.sol
- SDC reference implementation contractcontracts/SDCToken.sol
- Mintable token contract for unit teststest/SDC.js
- Unit tests for livecycle of sdc implementation
Used javascript based testing libraries for solidity
ethereum-waffle
: Waffle is a Solidity testing library. It allows you to write tests for your contracts with JavaScript.chai
: 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.solidity-coverage
: This library gives you coverage reports on unit tests with the help of Istanbul.
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
(should be better than 8.5.0) and node -v
(should be better than 16.14.2).
- 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