pcaversaccio / snekmate

State-of-the-art, highly opinionated, hyper-optimised, and secure 🐍Vyper smart contract building blocks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🐍 snekmate

πŸ•΅οΈβ€β™‚οΈ Test smart contracts License: AGPL-3.0-only npm package PyPI package

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 your foundry.toml file. The VyperDeployer contract offers two overloaded deployContract functions that allow the configuration of the target EVM version. Please note that since Vyper version 0.3.8 the default EVM version is set to shanghai.

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 via pip install git+https://github.com/pcaversaccio/snekmate.git@<branch> or forge install pcaversaccio/snekmate && forge update. Each branch, including the main 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:

🫑 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

About

State-of-the-art, highly opinionated, hyper-optimised, and secure 🐍Vyper smart contract building blocks.

License:GNU Affero General Public License v3.0


Languages

Language:Solidity 67.3%Language:Vyper 32.1%Language:JavaScript 0.6%Language:Python 0.0%