Off-the-shelf Solidity smart contracts. Built with my beloved Solidity template.
- Compatible with Solidity ^0.7.0
- Complementary to OpenZeppelin Contracts
- Promoting CarefulMath.sol instead of SafeMath.sol (see rationale here)
- Using Exponential.sol for fixed-point math
- Tested with Buidler and Waffle
I created this library for my own use, in order to avoid having to maintain the same contracts in different repositories. If you find it useful too, it's a win for the both of us.
Caveat
This is experimental, beta software and is provided on an "as is" and "as available" basis. I do not give any warranties and will not be liable for any loss, direct or indirect through continued use of this codebase.
Installation
With yarn:
$ yarn add @paulrberg/contracts
Or npm:
npm install @paulrberg/contracts
I adhere to Semantic Versioning, which means that your contracts won't break unexpectedly when upgrading to a newer minor version.
Usage
Once installed, you can use the contracts in the library by importing them:
pragma solidity ^0.7.0;
import "@paulrberg/contracts/math/CarefulMath.sol";
import "@paulrberg/contracts/token/erc20/Erc20.sol";
import "@paulrberg/contracts/token/erc20/Erc20Permit.sol";
contract MyToken is CarefulMath, Erc20, Erc20Permit {
constructor(
string memory name_,
string memory symbol_,
uint8 decimals_
) Erc20(name_, symbol_, decimals_) {}
}
Contributing
Pre Requisites
Before running any command, make sure to install dependencies:
$ yarn install
Compile
Compile the smart contracts with Buidler:
$ yarn compile
TypeChain
Compile the smart contracts and generate TypeChain artifacts:
$ yarn build
Lint Solidity
Lint the Solidity code:
$ yarn lint:sol
Lint TypeScript
Lint the TypeScript code:
$ yarn lint:ts
Test
Run the Mocha tests:
$ yarn test
Coverage
Generate the code coverage report:
$ yarn coverage
Clean
Delete the smart contract artifacts, the coverage reports and the Buidler cache:
$ yarn clean
Security
While I set a high bar for code quality and coverage, do not assume that this library is completely safe to use. The contracts have not been audited by a professional security researcher.
If you discover any security issues, report them via Keybase.
Acknowledgements
I am grateful to the authors of existing related projects from where I drew inspiration:
- OpenZeppelin Contracts
- Compound Protocol's Math Contracts
- Alberto Cuesta Caรฑada's Erc20Permit and Orchestrated
License
The contracts are released under the MIT License.