• Stars
    star
    103
  • Rank 331,296 (Top 7 %)
  • Language
    Solidity
  • Created over 2 years ago
  • Updated 8 months ago

Reviews

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

Repository Details

Benchmarks of popular contract implementations in solidity

Solidity Benchmarks

Benchmarks for popular implementations of contract standards.

⚠️ The gas usage shown in the benchmarks doesn't take into account the 21k gas added to every ethereum transaction

You can see benchmarks for different compiler versions on benchmarks/

The file data.json provides a json format of all the data used in the benchmarks. That file is generated by running the command make json.

Method used

We create a minimal implementation of each contract that uses the specific implementation as a base. Then for each of the methods we want to benchmark, we create a test contract that set the environment in the setUp function and each test only runs the specific function we're benchmarking, trying to reduce the noise as much as possible.

The gas usage shown here is not 100% accurate, but it's good enough to be able to compare the gas usage between the implementations.

All tests are generated using the template files in templates

All tables in the readmes are generated using the scripts in scripts

Contributing

There are many ways to contribute to this project

  • Add a snapshot for the latest solc version
  • Add or suggest a contract implementation (the instructions for adding are below)
  • Update a contract implementation
  • Enhance the codegen scripts

Setup for local development

  • Install foundry http://getfoundry.sh
  • You'll need python 3 installed to run the scripts under the scripts folder
  • Install the python dependencies pip install -r requirements.txt
  • git clone --recurse-submodules https://github.com/alephao/solidity-benchmarks.git

How to add a contract

  1. Create a minimal implementation on src/, the contract name and file name should follow the convention <Contract Type>_<Variation>.
  2. Implement the common interface that is in other files of the same contract type (for ERC721 for example, it's mint and safeMint functions)
  3. Add an entry to the contracts.<contract type>.variations property on test-cases.yml, following the examples there.
  4. Add an entry to scripts/.py's variants var following the examples there. It should map the variant name you used in the contract like ERC721_<Variant> to the name you want to appear on the table. E.g.:
  5. In case you added an ERC721 that's also ERC2309 compliant, add a another contract in the same file following the convention <Contract Type>_<Variation>_ERC2309, and add an entry to the contracts.ERC721.ERC2309Variations in the test-cases.yml
variations = {
    "OZ": "OpenZeppelin",
    "OZEnumerable": "OpenZeppelin Enumerable",
    "OZConsecutive": "OpenZeppelin Consecutive",
    "Solady": "Solady",
    "Solmate": "Solmate",
    "A": "ERC721A",
    "B": "ERC721B",
    "K": "ERC721K",
}
  1. Run the following commands:
make codegen
make snapshot
make readme
make json
  1. Add the contract to the list at the top of the <Contract Type>.md. (If you added a new ERC721, update the list on top of ERC721.md)

Quick links

ERC20

ERC721

ERC1155

More Repositories

1

nftool

A suite of tools for NFT generative art.
Go
153
star
2

erc721-batch-transfer

Transfer multiple ERC721 tokens in a single transaction
Solidity
39
star
3

CoreMLExample

An example of CoreML using a pre-trained VGG16 model
Swift
37
star
4

LLSpinner

The easiest way to handle a simple full screen activity indicator in iOS. Written in Swift.
Swift
37
star
5

nft-sale-proxy

A proxy to hide NFT metadata during the sale and prevent people from sniping specific NFTs.
Go
26
star
6

swift-rlp

Recursive Length Prefix encoding written in Swift
Swift
24
star
7

Stencil-CLI

Render a Stencil template by using a JSON or Yaml data source
Swift
17
star
8

solcery

Solidity code generation tool
Python
14
star
9

Reginald

Automate your pull-request review
TypeScript
13
star
10

StaticMulticall

EVM Multicall for view-only functions
Solidity
11
star
11

hevm

Easy to use Hevm cheatcodes contract
Solidity
11
star
12

solidity-genetics-benchmark

Solidity
9
star
13

lalainc-xcassetscop

Enforce configurations on Xcode assets
Ruby
8
star
14

tia-crawler

Gem para acessar os dados do TIA Mackenzista
Ruby
8
star
15

solidity-template

Opinionated solidity starter template with too many tools
TypeScript
7
star
16

xcode-ios-template

iOS project template: no storyboard, no scene delegate, no xcodeproj, no boilerplate, yes xcodegen, yes swiftformat, yes useful scripts.
Python
6
star
17

obk-ios

Our Big Kitchen iOS App for Volunteers
Swift
5
star
18

alephao.github.io

My personal website
HTML
5
star
19

swift-http-types-htmx

swift-http-types extensions for htmx
Swift
4
star
20

bitrise-step-s3-cache-push

A bitrise step to store your cache in a s3 bucket.
Go
4
star
21

homebrew-formulae

Collection of Homebrew Formulae
Ruby
4
star
22

genzin

Swift boilerplate generator for Rx + MVVM
Ruby
4
star
23

indepth

Swift
4
star
24

scholarship

Swift
3
star
25

nft-sale-proxy-examples

Makefile
3
star
26

3d-titan-tiki-contracts

Ethereum smart contracts of the Titan Tiki 3D collection
Solidity
3
star
27

minimal-watch-contract

JavaScript
3
star
28

tutorial-appstore-snapshot

Swift
3
star
29

macos-packer-anka

Packer templates for building macOS images with Anka
Makefile
3
star
30

brazilian-utils-elixir

Utilities library for Brazilian Businesses
Elixir
2
star
31

Margherita

An example of Bazel used in an iOS/Swift project
Swift
2
star
32

CoindarAPI

A wrapper around the Coindar API
Swift
2
star
33

Reginald-tests

JavaScript
2
star
34

coindar-ios

Swift
2
star
35

discuss-elixir-phoenix

Example elixir-phoenix project
Elixir
2
star
36

Loteria

Platform to generate lottery contracts in Ethereum
HTML
2
star
37

obk-web

CSS
2
star
38

smsmarketing

smsmarketing site
CSS
2
star
39

evm-poller

Poll a range of block numbers from an evm node every x seconds
Go
2
star
40

forgery-lib-test-issue

Solidity
1
star
41

gitstatus

Swift
1
star
42

cacheutil

Go
1
star
43

cryc

TypeScript
1
star
44

itsallaboutgenetics

Solving the traveling salesman problem with a genetic algorithm, written in TypeScript
TypeScript
1
star
45

defi-bindings

Go
1
star
46

spaceship-enterprise

CSS
1
star
47

govhack

Swift
1
star
48

bitrise-step-s3-cache-pull

a bitrise step to download your cache from a s3 bucket.
Go
1
star
49

gatsby-starter

Gatsby starter focused on developer productivity
JavaScript
1
star
50

flappy

Swift
1
star