• Stars
    star
    464
  • Rank 91,129 (Top 2 %)
  • Language
    Solidity
  • License
    GNU Affero Genera...
  • Created almost 2 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

State-of-the-art, highly opinionated, hyper-optimised, and secure ๐ŸVyper smart contract building blocks.

๐Ÿ snekmate

Test smart contracts License: AGPL v3 npm package PyPI package

State-of-the-art, highly opinionated, hyper-optimised, and secure ๐ŸVyper smart contract building blocks.

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
โ”œโ”€ auth
โ”‚  โ”œโ”€ Ownable โ€” "Owner-Based Access Control Functions"
โ”‚  โ”œโ”€ Ownable2Step โ€” "2-Step Ownership Transfer Functions"
โ”‚  โ”œโ”€ AccessControl โ€” "Multi-Role-Based Access Control Functions"
โ”œโ”€ extensions
โ”‚  โ”œโ”€ ERC2981 โ€” "ERC-721 and ERC-1155 Compatible ERC-2981 Reference Implementation"
โ”‚  โ”œโ”€ ERC4626 โ€” "Modern and Gas-Efficient ERC-4626 Tokenised Vault 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"
โ”œโ”€ 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"

๐ŸŽ› Installation

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

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

๐Ÿ‘ฉ๐Ÿผโ€โš–๏ธ 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 โœ… โœ… โœ…
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: 0x07bF3CDA34aA78d92949bbDce31520714AB5b228. I can pledge that I will use this money to help fix more existing challenges in the Ethereum ecosystem ๐Ÿค.

๐Ÿ’ข Disclaimer

More Repositories

1

reentrancy-attacks

A chronological and (hopefully) complete list of reentrancy attacks to date.
1,178
star
2

xdeployer

Hardhat plugin to deploy your smart contracts across multiple EVM chains with the same deterministic address.
Solidity
399
star
3

create2deployer

Helper smart contract to make easier and safer usage of the `CREATE2` EVM opcode.
Solidity
244
star
4

createx

Factory smart contract to make easier and safer usage of the `CREATE` and `CREATE2` EVM opcodes as well as of `CREATE3`-based (i.e. without an initcode factor) contract creations.
Solidity
208
star
5

hardhat-project-template-ts

A fully-fledged Hardhat project template based on TypeScript.
TypeScript
186
star
6

malleable-signatures

This repository implements a simplified PoC that demonstrates how signature malleability attacks using compact signatures can be executed.
Solidity
103
star
7

ecdsa-nonce-reuse-attack

This repository implements a Python function that recovers the private key from two different signatures that use the same random nonce during signature generation.
Python
73
star
8

tornado-cash-exploit

This repository implements a simplified PoC that showcases how a contract can morph. A similar approach was used as part of the governance attack on Tornado Cash in May 2023.
Solidity
44
star
9

metatx

A smart contract to enable ERC-20 token meta-transactions on Ethereum.
JavaScript
43
star
10

escrow-contract

A simple multilateral escrow smart contract for ETH and ERC-20 tokens governed by Cobie.
TypeScript
36
star
11

raw-tx

Two scripts to generate and execute a signed raw transaction with ethers.
TypeScript
26
star
12

torn-detector

Detect if a contract has been deployed in the latest (or predefined) block from an address that was previously funded through Tornado.Cash.
TypeScript
22
star
13

meth

The moment you Rust, you should look for your Mojo ๐Ÿ”ฅ.
20
star
14

solidity-games

A repository for Solidity-based smart contract games.
Solidity
19
star
15

batch-distributor

Helper smart contract for batch sending both native and ERC-20 tokens.
TypeScript
18
star
16

create-util

Helper smart contract to make easier and safer usage of the `CREATE` EVM opcode.
TypeScript
18
star
17

p256-verifier-vyper

P256 (a.k.a. secp256r1 elliptic curve) signature verification ๐ŸVyper contract.
Vyper
17
star
18

ethereum-key-generation-python

Generating Ethereum addresses in Python.
Python
13
star
19

mnemonic-to-private-key

A JavaScript script that converts the mnemonic phrase into a wallet private key using the ethers.js library.
JavaScript
13
star
20

fork-testing-evm-compatibility

This repository implements a simple fork test on Optimism that proves that the EVM behaviour of the forked chain is not identically replicated locally.
Solidity
12
star
21

pcaversaccio

My public profile.
11
star
22

erc20-permit-upgradeable

Permit-enabled, upgradeable ERC20 smart contract template.
TypeScript
11
star
23

tornado-cash-ether-withdrawal-decipherer

Deciphering the ether transactions in the Tornado.Cash withdrawals.
JavaScript
7
star
24

bitsquatting

Helper script for generating permutations of an ENS domain that differ by 1-bit from the original domain.
Python
7
star
25

mass-key-generation

A repository for mass public-private key generation (Bitcoin & Ethereum).
Java
6
star
26

ethereum-key-generation

A repository that shows how to generate a private / public key pair using web3.js or HD wallets.
JavaScript
5
star
27

erc20-oz-sdk

How to deploy an ERC20 smart contract using OpenZeppelin SDK and write a TokenExchange smart contract.
Solidity
4
star
28

tokenbridge-helium-ethereum

A tokenbridge between the Helium blockchain (native network) and the Ethereum blockchain (foreign network).
4
star
29

chainlink-price-feed

Retrieve the ETH/USD price feed from Chainlink's oracle using Infura.
JavaScript
4
star
30

connection-vscode-to-google-colab-gpus

A step-by-step guide to connecting the local Visual Studio Code to Google Colab's GPU runtime.
4
star
31

zksync-vyper-sandbox

A sandbox environment for zkSync Era Vyper compiler testing.
TypeScript
3
star
32

configurations

Monorepo for my personal configurations.
Shell
2
star
33

pool-viewer

Similar to an ETH2 block explorer, but focused only on recent data.
2
star
34

porini-community-token-contract

This is Porini's ERC-20 smart contract, whose tokens can activate communities to support conservation activities and learn about blockchain technology.
JavaScript
2
star
35

pcaversaccio.github.io

My personal website.
HTML
2
star
36

impact-dollar-token-contract

This is Impact Dollar's ERC-20 smart contract, whose tokens can deliver a demonstrable contribution to conservation and protected areas through digital collectibles.
JavaScript
2
star
37

payfoot-token-contract

This is PayFoot's ERC-20 smart contract, whose tokens are used as stablecoins in their ecosystem.
JavaScript
2
star
38

startfeld-token-contract

This is Startfeld's ERC-20 smart contract, whose tokens are used as vouchers in their ecosystem.
JavaScript
2
star
39

randao-distribution

Empirical distribution of the randomness beacon (=RANDAO) provided by the Beacon chain.
Python
2
star
40

saentis-gulden-token-contract

This is Sรคntis Gulden's ERC-20 smart contract, whose tokens are used as vouchers in their ecosystem.
JavaScript
1
star
41

block-explorer-swissdlt

A block explorer for the Swiss DLT blockchain.
TypeScript
1
star
42

interface-solc-test

Solidity
1
star
43

ath-erc20-token

Smart contract of the Alethena (ATH) token.
1
star