State-of-the-art, highly opinionated, hyper-optimised, and secure ๐Vyper smart contract building blocks.
Project description
๐ snekmate
State-of-the-art, highly opinionated, hyper-optimised, and secure ๐Vyper smart contract building blocks.
[!WARNING] This is experimental software and is provided on an "as is" and "as available" basis. We do not give any warranties and will not be liable for any losses incurred through any use of this code base.
๐ Contracts
src
โโโ snekmate
โโโ auth
โ โโโ Ownable โ "Owner-Based Access Control Functions"
โ โโโ Ownable2Step โ "2-Step Ownership Transfer Functions"
โ โโโ AccessControl โ "Multi-Role-Based Access Control Functions"
โ โโโ interfaces
โ โโโ IAccessControl โ "AccessControl Interface Definition"
โโโ extensions
โ โโโ ERC2981 โ "ERC-721 and ERC-1155 Compatible ERC-2981 Reference Implementation"
โ โโโ ERC4626 โ "Modern and Gas-Efficient ERC-4626 Tokenised Vault Implementation"
โ โโโ interfaces
โ โโโ IERC2981 โ "EIP-2981 Interface Definition"
โโโ governance
โ โโโ TimelockController โ "Multi-Role-Based Timelock Controller Reference Implementation"
โโโ tokens
โ โโโ ERC20 โ "Modern and Gas-Efficient ERC-20 + EIP-2612 Implementation"
โ โโโ ERC721 โ "Modern and Gas-Efficient ERC-721 + EIP-4494 Implementation"
โ โโโ ERC1155 โ "Modern and Gas-Efficient ERC-1155 Implementation"
โ โโโ interfaces
โ โโโ IERC20Permit โ "EIP-2612 Interface Definition"
โ โโโ IERC721Enumerable โ "EIP-721 Optional Enumeration Interface Definition"
โ โโโ IERC721Metadata โ "EIP-721 Optional Metadata Interface Definition"
โ โโโ IERC721Permit โ "EIP-4494 Interface Definition"
โ โโโ IERC721Receiver โ "EIP-721 Token Receiver Interface Definition"
โ โโโ IERC1155 โ "EIP-1155 Interface Definition"
โ โโโ IERC1155MetadataURI โ "EIP-1155 Optional Metadata Interface Definition"
โ โโโ IERC1155Receiver โ "EIP-1155 Token Receiver Interface Definition"
โ โโโ IERC4906 โ "EIP-4906 Interface Definition"
โโโ utils
โโโ Base64 โ "Base64 Encoding and Decoding Functions"
โโโ BatchDistributor โ "Batch Sending Both Native and ERC-20 Tokens"
โโโ CreateAddress โ "`CREATE` EVM Opcode Utility Function for Address Calculation"
โโโ Create2Address โ "`CREATE2` EVM Opcode Utility Functions for Address Calculations"
โโโ ECDSA โ "Elliptic Curve Digital Signature Algorithm (ECDSA) Functions"
โโโ SignatureChecker โ "ECDSA and EIP-1271 Signature Verification Functions"
โโโ EIP712DomainSeparator โ "EIP-712 Domain Separator"
โโโ Math โ "Standard Mathematical Utility Functions"
โโโ MerkleProofVerification โ "Merkle Tree Proof Verification Functions"
โโโ Multicall โ "Multicall Functions"
โโโ interfaces
โโโ IERC5267 โ "EIP-5267 Interface Definition"
๐ Installation
[!IMPORTANT]
๐ snekmate uses a ZeroVer-based versioning scheme. This means ๐ snekmate's major version will never exceed the first and most important number in computing: zero.
We offer three convenient ways to install the ๐ snekmate contracts:
1๏ธโฃ Foundry
You can install ๐ snekmate via submodules using Foundry with:
forge install pcaversaccio/snekmate
If you want to leverage ๐ snekmate's
VyperDeployer
contract for your own testing, ensure that you compile the Vyper contracts with the same EVM version as configured in yourfoundry.toml
file. TheVyperDeployer
contract offers two overloadeddeployContract
functions that allow the configuration of the target EVM version. Please note that since Vyper version0.3.8
the default EVM version is set toshanghai
.
2๏ธโฃ PyPI
You can install ๐ snekmate from PyPI with:
pip install snekmate
You can use
pip install snekmate -t .
to install the contracts directly into the current working directory!
3๏ธโฃ npm
You can install ๐ snekmate from npm with:
npm install --save-dev snekmate
Or if you are using Yarn:
yarn add --dev snekmate
In case you are using pnpm, invoke:
pnpm add --save-dev snekmate
[!CAUTION] It is possible to install the latest versions of
main
or any other branch locally viapip install git+https://github.com/pcaversaccio/snekmate.git@<branch>
orforge install pcaversaccio/snekmate && forge update
. Each branch, including themain
branch, must be understood as a development branch that should be avoided in favour of tagged releases. The release process includes security measures that the repository branches do not guarantee.
๐ฉ๐ผโโ๏ธ Tests
This repository contains Foundry-based unit tests, property-based tests (i.e. fuzzing), and invariant tests for all contracts, if applicable. All tests are run as part of the CI pipeline test-contracts
.
[!NOTE] An invariant is a property of a program that should always hold true. Fuzzing is a way of checking whether the invariant is falsifiable.
Contract | Unit Tests | Property-Based Tests | Invariant Tests |
---|---|---|---|
Ownable |
โ | โ | โ |
Ownable2Step |
โ | โ | โ |
AccessControl |
โ | โ | โ |
ERC2981 |
โ | โ | โ |
ERC4626 |
โ | โ | โ |
TimelockController |
โ | โ | โ |
ERC20 |
โ | โ | โ |
ERC721 |
โ | โ | โ |
ERC1155 |
โ | โ | โ |
Base64 |
โ | โ | โ |
BatchDistributor |
โ | โ | โ |
CreateAddress |
โ | โ | โ |
Create2Address |
โ | โ | โ |
ECDSA |
โ | โ | โ |
SignatureChecker |
โ | โ | โ |
EIP712DomainSeparator |
โ | โ | โ |
Math |
โ | โ | โ |
MerkleProofVerification |
โ | โ | โ |
Multicall |
โ | โ | โ |
โ Test Type Implemented โ โ Test Type Not Implemented
๐๐ผ Acknowledgements
This repository is inspired by or directly modified from many sources, primarily:
- ApeAcademy
- Batch Distributor
CREATE
Factory- Disperse Research
- Multicall
- OpenZeppelin Contracts
- solady
- solmate
๐ซก Contributing
๐ snekmate only exists thanks to its contributors. There are many ways to get involved and contribute to our high-quality and secure smart contracts. Check out our Contribution Guidelines!
๐ธ Donation
I am a strong advocate of the open-source and free software paradigm. However, if you feel my work deserves a donation, you can send it to this address: 0xe9Fa0c8B5d7F79DeC36D3F448B1Ac4cEdedE4e69
. I can pledge that I will use this money to help fix more existing challenges in the Ethereum ecosystem ๐ค.
๐ข Disclaimer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.