cairomate โข
Structured, dependable legos for starknet development.
Directory Structure
contracts
โโ defi
โ โโ ChainlinkPriceOracle โ "Simple price oracle using Chainlink's V3 Aggregator"
โ โโ MultiExchange โ "Permissionless, ERC1155 Multitoken Exchange"
โ โโ StakingRewards โ "Flexible, stripped staking rewards measured by blocks"
โโ interfaces
โ โโ IAccount โ "Account Interface"
โ โโ IAggregatorV3 โ "Chainlink V3 Aggregator Interface"
โ โโ IERC20 โ "ERC20 Contract Interface"
โ โโ IERC165 โ "ERC165 Contract Interface"
โ โโ IERC721 โ "ERC721 Contract Interface"
| โโ INERC721 โ "N-ERC721 Contract Interface (felt-based ERC721)"
โ โโ IERC1155 โ "ERC1155 Contract Interface"
โโ tokens
โ โโ ERC20 โ "Modern and gas efficient ERC20 + EIP-2612 implementation"
โ โโ ERC721
โ โ โโ ERC721 - "Modern and gas efficient ERC721 | Uint256-based + EIP-2612 implementation"
โ โ โโ N-ERC721 - "Modern and gas efficient ERC721 | felt-based + EIP-2612 implementation"
โ โโ ERC1155 โ "Modern and gas efficient ERC1155 + EIP-165 implementation"
โโ utils
โ โโ Account โ "Stripped account"
โ โโ Ownable โ "Minimal, ownable contract instance"
โ โโ Context โ "Port of OZ's Solidity Context Abstraction"
โ โโ Pausible โ "Pausible Solidity Functionality"
tests
โโ test_StakingRewards โ "Flexible, stripped staking rewards measured by blocks"
โโ test_ERC20 - "Test ERC20 contract"
โโ test_ERC721 - "Test ERC721 contract"
โโ test_Ownable - "Test Ownable contract"
Installation
First time?
Further installation instructions provided in the cairo-lang docs
Before installing Cairo on your machine, you need to install gmp
:
sudo apt install -y libgmp3-dev # linux
brew install gmp # mac
If you have any troubles installing gmp on your Apple M1 computer, hereโs a list of potential solutions.
For VSCode support:
Download cairo-0.7.0.vsix
from https://github.com/starkware-libs/cairo-lang/releases/tag/v0.7.0
And run:
code --install-extension cairo-0.7.0.vsix
Set up the project
Clone the repository
git clone [email protected]:abigger87/cairomate.git
cd
into it and create a Python virtual environment:
cd cairomate
python3 -m venv env
source env/bin/activate
Install the Nile dev environment and then run install
to get the Cairo language, a local network, and a testing framework.
pip3 install cairo-nile
nile install
Usage
Compile the contracts
nile compile
Run tests
pytest
Running a specific test file (eg tests/test_ERC20.py
):
pytest tests/test_ERC20.py
Test a specific test case:
pytest tests/test_ERC20.py -k 'test_mint'
Extending Cairo contracts
There's no clear contract extensibility pattern for Cairo smart contracts yet. In the meantime the best way to extend our contracts is copypasting and modifying them at your own risk. Remember this contracts are still under development and they have not gone through any audit or security review whatsoever.
Acknowledgements
Big thanks to:
Security
This project is still in a very early and experimental phase. It has never been audited nor thoroughly reviewed for security vulnerabilities. Do not use in production.
Please report any security issues you find by opening up an issue in this reposisitory.
License
Cairomate Contracts are released under the AGPL-3.0-only.