Snekmate
State-of-the-art, highly opinionated, hyper-optimised, and secure ๐Vyper smart contract building blocks.
Install / Use
/learn @pcaversaccio/SnekmateREADME
๐ snekmate <!-- omit from toc -->
<img src=https://github.com/pcaversaccio/snekmate/assets/25297591/a899251b-d22b-4cb3-8109-88facba53d6a width="1050"/>
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
- ๐ Installation
- ๐ง Usage
- ๐ฉ๐ผโโ๏ธ Tests
- ๐ฎโโ๏ธ Audits
- ๐๐ผ Acknowledgements
- ๐ซก Contributing
- ๐ธ Donation
- ๐ Licence
- ๐ข Disclaimer
๐ Contracts
src
โโโ snekmate
โโโ auth
โ โโโ ownable โ "Owner-Based Access Control Functions"
โ โโโ ownable_2step โ "2-Step Ownership Transfer Functions"
โ โโโ access_control โ "Multi-Role-Based Access Control Functions"
โ โโโ interfaces
โ โ โโโ IAccessControl โ "AccessControl Interface Definition"
โ โโโ mocks
โ โโโ ownable_mock โ "`ownable` Module Reference Implementation"
โ โโโ ownable_2step_mock โ "`ownable_2step` Module Reference Implementation"
โ โโโ access_control_mock โ "`access_control` Module Reference Implementation"
โโโ 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"
โ โโโ mocks
โ โโโ erc2981_mock โ "`erc2981` Module Reference Implementation"
โ โโโ erc4626_mock โ "`erc4626` Module Reference Implementation"
โโโ governance
โ โโโ timelock_controller โ "Multi-Role-Based Timelock Controller Reference Implementation"
โ โโโ mocks
โ โโโ timelock_controller_mock โ "`timelock_controller` Module 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"
โ โโโ mocks
โ โโโ erc20_mock โ "`erc20` Module Reference Implementation"
โ โโโ erc721_mock โ "`erc721` Module Reference Implementation"
โ โโโ erc1155_mock โ "`erc1155` Module Reference Implementation"
โโโ utils
โโโ base64 โ "Base64 Encoding and Decoding Functions"
โโโ batch_distributor โ "Batch Sending Both Native and ERC-20 Tokens"
โโโ block_hash โ "Utility Functions to Access Historical Block Hashes"
โโโ create โ "`CREATE` EVM Opcode Utility Functions"
โโโ create2 โ "`CREATE2` EVM Opcode Utility Functions"
โโโ create3 โ "`CREATE3`-Based Utility Functions"
โโโ ecdsa โ "Elliptic Curve Digital Signature Algorithm (ECDSA) Secp256k1-Based Functions"
โโโ p256 โ "Elliptic Curve Digital Signature Algorithm (ECDSA) Secp256r1-Based Functions"
โโโ message_hash_utils โ "Signature Message Hash Utility Functions"
โโโ signature_checker โ "ECDSA and EIP-1271 Signature Verification Functions"
โโโ eip712_domain_separator โ "EIP-712 Domain Separator"
โโโ eip7702_utils โ "EIP-7702 Utility Functions"
โโโ math โ "Standard Mathematical Utility Functions"
โโโ merkle_proof_verification โ "Merkle Tree Proof Verification Functions"
โโโ multicall โ "Multicall Functions"
โโโ pausable โ "Pausable Functions"
โโโ interfaces
โ โโโ IERC1271 โ "EIP-1271 Interface Definition"
โ โโโ IERC5267 โ "EIP-5267 Interface Definition"
โโโ mocks
โโโ base64_mock โ "`base64` Module Reference Implementation"
โโโ batch_distributor_mock โ "`batch_distributor` Module Reference Implementation"
โโโ block_hash_mock โ "`block_hash` Module Reference Implementation"
โโโ create_mock โ "`create` Module Reference Implementation"
โโโ create2_mock โ "`create2` Module Reference Implementation"
โโโ create3_mock โ "`create3` Module Reference Implementation"
โโโ ecdsa_mock โ "`ecdsa` Module Reference Implementation"
โโโ p256_mock โ "`p256` Module Reference Implementation"
โโโ message_hash_utils_mock โ "`message_hash_utils` Module Reference Implementation"
โโโ signature_checker_mock โ "`signature_checker` Module Reference Implementation"
โโโ eip712_domain_separator_mock โ "`eip712_domain_separator` Module Reference Implementation"
โโโ eip7702_utils_mock โ "`eip7702_utils` Module Reference Implementation"
โโโ math_mock โ "`math` Module Reference Implementation"
โโโ merkle_proof_verification_mock โ "`merkle_proof_verification` Module Reference Implementation"
โโโ multicall_mock โ "`multicall` Module Reference Implementation"
โโโ pausable_mock โ "`pausable` Module Reference Implementation"
๐ 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๏ธโฃ PyPI
You can install ๐ snekmate from PyPI with:
pip install snekmate
When using the ๐Vyper CLI, the search path defaults to the current working directory and the Python
sys.path. As a result, all imported ๐ snekmate contracts (e.g.from snekmate.tokens import erc20) are seamlessly located during compilation.
2๏ธโฃ Foundry
You can install ๐ snekmate via submodules using Foundry with:
forge install pcaversaccio/snekmate
[!NOTE] If you want to leverage ๐ snekmate's
VyperDeployercontract for your own testing, ensure that you compile the ๐Vyper contracts with the same EVM version as configured in yourfoundry.tomlfile. TheVyperDeployercontract offers two overloadeddeployContractfunctions that allow the configuration of the target EVM version. Please note that since ๐Vyper version0.4.3the default EVM version is set toprague. Furthermore, theVyperDeployercontract relies on the Python scriptcompile.pyfor successful compilation and deployment. Always use theVyperDeployercontract alongside with the aforementioned script.
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
If you are a Bun user, run:
bun add --dev snekmate
[!CAUTION] It is possible to install the latest versions of
mainor any other branch locally viapip install git+https://github.com/pcaversaccio/snekmate.git@<branch>orforge install pcaversaccio/snekmate && forge update. Each branch, including themainbranch, 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.
๐ง Usage
๐Vyper favours code reuse through composition rather than inheritance (Solidity inheritance makes it easy to break the Liskov Substitution Principle). A ๐Vyper module encapsulates everything required for code reuse, from type and function declarations to state. All ๐ snekmate contracts are ๐Vyper modules. Thus, many of the ๐ snekmate contracts do not compile independently, but you must import and initializes them. Please note that if a module is stateless, it does not require the k
