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 903150
ERC721B 918310
ERC721K 1002924
OpenZeppelin Consecutive 1014508
OpenZeppelin Enumerable 1120129
OpenZeppelin 848572
Solady 611428
Solmate 797867

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 776046 776145 776079 776189 776123 776101
OpenZeppelin Consecutive 850635 850734 850668 850778 850712 850690

Write methods

mint

How much gas to mint N tokens?

Implementation 1 2 3 4 5 10 50 100
ERC721A 56978 59083 61042 62894 64872 74535 151971 248975
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 59956 61942 63923 65748 67838 77460 154825 251637
ERC721B 55363 57644 59920 62040 64425 75522 164687 276249
ERC721K 60521 62577 64628 66523 68683 78655 158820 259132
OpenZeppelin Consecutive 82114 107994 133869 159588 185572 314664 1347794 2639322
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 69705 106820 195215 305837
ERC721B 8453 8560 8475 8497
ERC721K 73478 112150 207551 327009
OpenZeppelin Consecutive 20785 20892 20807 20829
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 53024 90054 178468 289046
ERC721B 294996 273760 179214 43992
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 70090 107120 195534 306156
ERC721B 294962 273726 179180 44002
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 55835 92799 181301 291817
ERC721B 297857 276555 182097 46813
ERC721K 59323 97844 193352 312705
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 72901 109865 198367 309011
ERC721B 297823 276521 182063 46907
ERC721K 76389 114910 210418 329899
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