Skip to content

Latest commit

 

History

History
282 lines (229 loc) · 11.2 KB

File metadata and controls

282 lines (229 loc) · 11.2 KB

ERC721 Benchmark

Benchmarks for implementations of the ERC20 standard.

The most popular way of implementing ERC721 is by having sequential ids for each token, so if a collection has 10000 tokens, the ids of each token are in the range 1~10000. Some of the latest implementations focus on making mint cheaper at the cost of an expensive transfer, this bechmark highlights that.

We'll be comparing the following implementations:

Methods TODO

  • deploy
  • mint (not in the specification, but common)
  • safeMint (not in the specification, but common)
  • burn (not in the specification, but common)
  • balanceOf
  • ownerOf
  • transferFrom
  • safeTransferFrom
  • approve
  • setApprovalForAll
  • getApproved
  • isApprovedForAll

Deployment

How much gas to deploy the contract as is?

Implementation --
ERC721A 912156
ERC721B 920104
ERC721K 1006723
OpenZeppelin Consecutive 1029935
OpenZeppelin Enumerable 1121923
OpenZeppelin 850365
Solady 611828
Solmate 801061

Deployment with ERC2309 minting

How much gas to deploy the ERC2309 compliant contracts when minting N tokens in the constructor?

Implementation 5 10 50 100 200 300
ERC721A 779240 779339 779273 779383 779317 779295
OpenZeppelin Consecutive 852448 852547 852481 852591 852525 852503

Write methods

mint

How much gas to mint N tokens?

Implementation 1 2 3 4 5 10 50 100
ERC721A 57002 59107 61066 62918 64896 74559 151995 248999
ERC721B 52176 54576 56830 58977 61250 72388 161624 273378
ERC721K 57609 59784 61813 63735 65783 75796 156032 256536
OpenZeppelin Consecutive 79151 104919 130541 156056 181697 309675 1333631 2613785
OpenZeppelin Enumerable 146003 260464 374779 488987 603321 1174764 5746440 11461244
OpenZeppelin 74324 99250 124030 148703 173502 297270 1287546 2525600
Solady 74108 98839 123424 147902 172506 295299 1277775 2506079
Solmate 74329 99260 124045 148723 173527 297320 1287796 2526100

safeMint

How much gas to safeMint N tokens?

Implementation 1 2 3 4 5 10 50 100
ERC721A 59980 61966 63947 65772 67862 77484 154849 251661
ERC721B 55363 57644 59920 62040 64425 75522 164687 276249
ERC721K 60524 62580 64631 66526 68686 78658 158823 259135
OpenZeppelin Consecutive 82113 107977 133836 159539 185507 314519 1347009 2637737
OpenZeppelin Enumerable 149000 263557 378109 492505 607166 1179643 5759853 11485231
OpenZeppelin 77299 102321 127338 152199 177325 302127 1300937 2549565
Solady 77091 101924 126752 151424 176361 300218 1291468 2530646
Solmate 77268 102257 127241 152069 177162 301799 1299284 2546246

burn

How much gas to burn the nth token?

Implementation 1 10 50 100
ERC721A 69732 106847 195242 305864
ERC721B 8453 8560 8475 8497
ERC721K 73478 112150 207551 327009
OpenZeppelin Consecutive 20779 20886 20801 20823
OpenZeppelin Enumerable 47407 51972 51904 51922
OpenZeppelin 18241 18348 18263 18285
Solady 18146 18253 18168 18190
Solmate 18212 18319 18234 18256

transferFrom

How much gas to transfer the nth token id if you own all tokens from 1 to 100?

To a wallet that already owns a token from the collection

Implementation 1 10 50 100
ERC721A 53027 90057 178471 289049
ERC721B 294990 273754 179208 43986
ERC721K 56471 95058 190478 309892
OpenZeppelin Consecutive 28826 28848 28782 28760
OpenZeppelin Enumerable 79656 67378 67312 67290
OpenZeppelin 28538 28560 28494 28472
Solady 28004 28026 27960 27938
Solmate 28433 28455 28389 28367

To a wallet that owns no token from the collection

Implementation 1 10 50 100
ERC721A 70093 107123 195537 306159
ERC721B 294956 273720 179174 43996
ERC721K 73537 112124 207544 327002
OpenZeppelin Consecutive 45892 45914 45848 45870
OpenZeppelin Enumerable 76822 79644 79578 79600
OpenZeppelin 45604 45626 45560 45582
Solady 45070 45092 45026 45048
Solmate 45499 45521 45455 45477

safeTransferFrom

How much gas to transfer the nth token id if you own all tokens from 1 to 100?

To a wallet that already owns a token from the collection

Implementation 1 10 50 100
ERC721A 55838 92802 181304 291820
ERC721B 297851 276549 182091 46807
ERC721K 59317 97838 193346 312699
OpenZeppelin Consecutive 31640 31596 31618 31534
OpenZeppelin Enumerable 82484 70140 70162 70078
OpenZeppelin 31344 31300 31322 31238
Solady 30676 30632 30654 30570
Solmate 31169 31125 31147 31063

To a wallet that owns no token from the collection

Implementation 1 10 50 100
ERC721A 72904 109868 198370 309014
ERC721B 297817 276515 182057 46901
ERC721K 76383 114904 210412 329893
OpenZeppelin Consecutive 48706 48662 48684 48728
OpenZeppelin Enumerable 79650 82406 82428 82472
OpenZeppelin 48410 48366 48388 48432
Solady 47742 47698 47720 47764
Solmate 48235 48191 48213 48257

setApprovalForAll

How much gas for setApprovalForAll?

Implementation --
ERC721A 32787
ERC721B 32852
ERC721K 32804
OpenZeppelin Consecutive 32832
OpenZeppelin Enumerable 32841
OpenZeppelin 32775
Solady 32633
Solmate 32758

approve

How much gas to approve the nth token id if you own all tokens from 1 to 100?

Implementation 1 10 50 100
ERC721A 37039 56991 145449 256005
ERC721B 271322 250108 155606 37462
ERC721K 37507 59016 154480 273872
OpenZeppelin Consecutive 35093 35137 35115 35071
OpenZeppelin Enumerable 34926 34970 34948 34904
OpenZeppelin 34926 34970 34948 34904
Solady 34707 34751 34729 34685
Solmate 34830 34874 34852 34808

View methods

balanceOf

How much gas to run balanceOf in an account with N tokens.

Implementation 1 10 50 100
ERC721A 7934 7873 7851 7829
ERC721B 2719313 2719495 2720553 2721881
ERC721K 7975 7914 7892 7870
OpenZeppelin Consecutive 7906 7845 7823 7801
OpenZeppelin Enumerable 8017 7956 7934 7912
OpenZeppelin 7931 7870 7848 7826
Solady 7894 7833 7811 7789
Solmate 7939 7878 7856 7834

ownerOf

How much gas to find the owner of a token when the owner owns 100 tokens and the token to find is the nth token.

Implementation 1 10 50 100
ERC721A 10132 30018 118564 229028
ERC721B 244356 223076 128662 10426
ERC721K 10576 32019 127571 246872
OpenZeppelin Consecutive 8034 8012 8078 7942
OpenZeppelin Enumerable 7990 7968 8034 7898
OpenZeppelin 7924 7902 7968 7832
Solady 7909 7887 7953 7817
Solmate 7900 7878 7944 7808

getApproved

How much gas to find the approved address of the nth token when the onwer owns 100 tokens and there are no approved addresses.

Implementation 1 10 50 100
ERC721A 10110 30062 118564 229076
ERC721B 244334 223120 128662 10474
ERC721K 10554 32063 127571 246920
OpenZeppelin Consecutive 8012 8056 8078 7990
OpenZeppelin Enumerable 7968 8012 8034 7946
OpenZeppelin 7902 7946 7968 7880
Solady 7887 7931 7953 7865
Solmate 7878 7922 7944 7856

isApprovedForAll

How much gas to check if an address is allowed to control another's nfts.

Implementation --
ERC721A 8226
ERC721B 8270
ERC721K 8211
OpenZeppelin Consecutive 8204
OpenZeppelin Enumerable 8250
OpenZeppelin 8184
Solady 8081
Solmate 8189