Skip to main content

๐Ÿ 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.

๐Ÿ“œ 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"
        โ”œโ”€โ”€ 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"
            โ”œโ”€โ”€ 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

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

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

๐Ÿ”ง 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 keyword initializes (or uses) for initialisation (or usage). Each module contract has an associated mock contract in the mock/ directory, which is part of the associated contract subdirectory. These mock contracts are very illustrative of how ๐Ÿ snekmate contracts can be used as ๐ŸVyper modules.

Please read here to learn more about using ๐ŸVyper modules.

๐Ÿ‘ฉ๐Ÿผโ€โš–๏ธ Tests

This repository contains Foundry-based unit tests, property-based tests (i.e. stateless fuzzing), and invariant tests (i.e. stateful fuzzing) for all contracts, if applicable. All tests are run as part of the CI pipeline test-contracts.

Contract Unit Tests Property-Based Tests Invariant Tests
ownable โœ… โœ… โœ…
ownable_2step โœ… โœ… โœ…
access_control โœ… โœ… โœ…
erc2981 โœ… โœ… โœ…
erc4626 โœ… โœ… โœ…
timelock_controller โœ… โœ… โœ…
erc20 โœ… โœ… โœ…
erc721 โœ… โœ… โœ…
erc1155 โœ… โœ… โœ…
base64 โœ… โŒ โŒ
batch_distributor โœ… โœ… โœ…
block_hash โœ… โœ… โŒ
create โœ… โœ… โŒ
create2 โœ… โœ… โŒ
create3 โœ… โœ… โŒ
ecdsa โœ… โœ… โŒ
p256 โœ… โœ… โŒ
message_hash_utils โœ… โœ… โŒ
signature_checker โœ… โœ… โŒ
eip712_domain_separator โœ… โœ… โŒ
math โœ… โœ… โŒ
merkle_proof_verification โœ… โœ… โŒ
multicall โœ… โŒ โŒ
pausable โœ… โœ… โœ…

โœ… Test Type Implemented โ€ƒ โŒ Test Type Not Implemented

Furthermore, the echidna-based property tests for the erc20 and erc721 contracts are available in the test/tokens/echidna/ directory. You can run the tests by invoking:

# Run Echidna ERC-20 property tests.
~$ FOUNDRY_PROFILE=echidna echidna test/tokens/echidna/ERC20Properties.sol --contract CryticERC20ExternalHarness --config test/echidna.yaml

# Run Echidna ERC-721 property tests.
~$ FOUNDRY_PROFILE=echidna echidna test/tokens/echidna/ERC721Properties.sol --contract CryticERC721ExternalHarness --config test/echidna.yaml

Eventually, the halmos-based symbolic tests for the erc20, erc721, erc1155, and math contracts are available in the test/tokens/halmos/ and test/utils/halmos/ directories. You can run the tests by invoking:

# Run Halmos ERC-20 symbolic tests.
~$ FOUNDRY_PROFILE=halmos halmos --contract ERC20TestHalmos --config test/halmos.toml

# Run Halmos ERC-721 symbolic tests. Be careful, this is a (very!) time-consuming operation.
~$ FOUNDRY_PROFILE=halmos halmos --contract ERC721TestHalmos --config test/halmos.toml

# Run Halmos ERC-1155 symbolic tests. Be careful, this is a (very!) time-consuming operation.
~$ FOUNDRY_PROFILE=halmos halmos --contract ERC1155TestHalmos --config test/halmos.toml

# Run Halmos math symbolic tests.
~$ FOUNDRY_PROFILE=halmos halmos --contract MathTestHalmos --config test/halmos.toml

๐Ÿ‘ฎโ€โ™€๏ธ Audits

Although the ๐Ÿ snekmate contracts have not (yet) undergone a full comprehensive audit, selected library modules integrated into specific protocols (such as Curve) have been thoroughly reviewed within the scope of prior audits. The corresponding audit reports are available here.

๐Ÿ™๐Ÿผ 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 ๐Ÿค.

๐Ÿ“„ Licence

This software is released under the GNU Affero General Public License v3.0 only (AGPL-3.0-only) by default.

We believe in fostering a collaborative and open ecosystem. The AGPL-3.0-only licence keeps the code free, the knowledge shared, and the doors open. It stands as a quiet rebellion against control, a promise that what is built in the open will remain in the open, owned by no one and available to all.

โš–๏ธ Dual-Licensing Option

We understand that AGPL-3.0-only-licensed software may not be suitable for all use cases, particularly in cases involving:

  • Proprietary or closed-source projects,
  • Licence incompatibilities, or
  • Commercial applications with conflicting requirements.

For such scenarios, we offer an alternative licence under the MIT License, granted at our sole discretion.

๐Ÿ“ฉ Requesting an MIT License

If you have substantial reasons for requiring a more permissive licence, such as those outlined above, feel free to contact us via email to request access to the software under the MIT License.

Each request is evaluated on a case-by-case basis, and we will provide the MIT License if deemed appropriate.

๐Ÿ’ข Disclaimer

Metadata

Release files for snekmate 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snekmate 0.1.2
File Size Uploaded
snekmate-0.1.2.tar.gz 102.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for snekmate 0.1.2
File Interpreter ABI Platform
snekmate-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 222.7 kB

Release files / snekmate-0.1.2.tar.gz

Download URL snekmate-0.1.2.tar.gz
Size 102.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8ed2c6a29b90424543d1792599c5c0b5ccf6988931b43029d1ca7e520a045038
BLAKE2b-256 checksum
How to use checksums
a4f55b285024f0a18e699f2b144d9821b2572e8665331261c9078fdad6a7aa38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 25, 2025.

Transparency log

Release files / snekmate-0.1.2-py3-none-any.whl

Download URL snekmate-0.1.2-py3-none-any.whl
Size 120.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df439ba25843f52e6d7e1b58000192f77cd0a5caa9a756075655ead2b66e6314
BLAKE2b-256 checksum
How to use checksums
2d94c7e58d2b19e05c91454ca64bdeb109969e4fac580c7eb2a50994859b1379
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 25, 2025.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page