README
Contracts
Off-the-shelf Solidity smart contracts. Built with my beloved Solidity template.
- Designed for Solidity >=0.8.4
- Complementary to OpenZeppelin Contracts
- Promotes PRBMath as a fixed-point math library for Solidity
- Well-documented via NatSpec comments
- Thoroughly tested with Hardhat and Waffle
I created this library for my own use, to avoid having to maintain the same contracts in different repositories. If you find it useful too, it's a win for both of us.
Caveat Emptor
This is experimental 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 semver, which means that your contracts won't break unexpectedly when upgrading to a
newer minor version of @paulrberg/contracts
.
Usage
Once installed, you can use the contracts like this:
pragma solidity >=0.8.4;
import "@paulrberg/contracts/math/PRBMathUD60x18.sol";
import "@paulrberg/contracts/token/erc20/Erc20.sol";
import "@paulrberg/contracts/token/erc20/Erc20Permit.sol";
contract MyToken is Erc20, Erc20Permit {
using PRBMathUD60x18 for uint256;
constructor(
string memory name_,
string memory symbol_,
uint8 decimals_
) Erc20Permit(name_, symbol_, decimals_) {}
}
Contributing
Pre Requisites
Before running any command, make sure to install dependencies:
$ yarn install
Compile
Compile the smart contracts with Hardhat:
$ yarn compile
TypeChain
Compile the smart contracts and generate TypeChain artifacts:
$ yarn typechain
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 Hardhat cache:
$ yarn clean
Security
While I set a high bar for code quality and test coverage, you shouldn't assume that this library is completely safe to use. The contracts have not yet been audited by a security researcher. If you discover any security issues, please report them via Keybase.
Acknowledgements
I am grateful to the authors of existing related projects:
- OpenZeppelin Contracts
- Alberto Cuesta CaƱada's Erc20Permit and Orchestrated
License
The contracts are released under the WTFPL License.