System Contracts
This repo is used to store solidity smart contracts. Also here must be unit tests for smart contracts.
Installing
$ npm i @q-dev/contracts
Usage
pragma solidity 0.8.9;
import "@q-dev/contracts/ContractRegistry.sol";
contract Example{
address reg = 0xc3E589056Ece16BCB88c6f9318e9a7343b663522;
function getQUSD() public view returns (address _addr){
_addr = ContractRegistry(reg).getAddress("defi.QUSD.coin");
}
}
Generating go code
-
Compile abigen if you don't have it yet:
1.1 Pull recent q-client
1.2. $ make all
1.3. put abigen from build/bin/abigen of q-client to ./bin of this repo.
-
Generate code with $ ./generate.sh
Notes:
- check that generated code have imports like
gitlab.com/q-dev/q-client, not github.com/ethereum/go-ethereum
Contribute
pre-commit hook activating
$ npx husky install
prettier
To check and fix codestyle bugs you should run prettier
$ npm run prettier
bytecode size
(python 3 installation required)
You may check bytecode size of each contract via
$ npm run contract-size
NatSpec usage
(python 3 installation required)
Also all public and external methods used by external users should have complete NatSpec. You may check current conformity via
$ npm run spec-check
Tests
For testing the system you should run Ganache CLI:
$ npm run private-network
Then you may run tests via
$ npm run test
Documentation
There you may find usage examples and descriptions of all methods:
https://q-dev.gitlab.io/system-contracts/
License
LGPL 3.0: https://gitlab.com/q-dev/system-contracts/-/blob/master/LICENSE