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 882892
ERC721B 898258
ERC721K 1028988
OpenZeppelin Consecutive 1006682
OpenZeppelin Enumerable 1126329
OpenZeppelin 846147
Solady 601182
Solmate 805468

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 769375 769471 769405 769515 769449 769427
OpenZeppelin Consecutive 848099 848195 848129 848239 848173 848151

Write methods

mint

How much gas to mint N tokens?

Implementation 1 2 3 4 5 10 50 100
ERC721A 57043 59167 61159 63041 65055 74883 153639 252293
ERC721B 52292 54786 57148 59400 61784 73462 167018 284172
ERC721K 58048 60192 62204 64106 66140 76068 155624 255278
OpenZeppelin Consecutive 79197 104979 130629 156169 181841 309959 1335035 2616589
OpenZeppelin Enumerable 146042 260518 374862 489096 603462 1175050 5747886 11464140
OpenZeppelin 74337 99252 124035 148708 173513 297296 1287692 2525896
Solady 74111 98813 123383 147843 172435 295153 1277029 2504583
Solmate 74328 99251 124042 148723 173536 297359 1288075 2526679

safeMint

How much gas to safeMint N tokens?

Implementation 1 2 3 4 5 10 50 100
ERC721A 60025 62039 64053 65913 68032 77821 156511 254978
ERC721B 55495 57879 60263 62493 64982 76621 170111 287078
ERC721K 60960 62994 65028 66908 69047 78936 158426 257893
OpenZeppelin Consecutive 82227 108175 134123 159917 185970 315429 1351484 2646667
OpenZeppelin Enumerable 149057 263659 378261 492709 607416 1180145 5762360 11490243
OpenZeppelin 77330 102371 127412 152299 177445 302369 1302144 2551977
Solady 77109 101942 126775 151454 176392 300276 1291731 2531164
Solmate 77247 102237 127227 152063 177158 301827 1299557 2546824

burn

How much gas to burn the nth token?

Implementation 1 10 50 100
ERC721A 69763 106903 195420 306192
ERC721B 8500 8605 8522 8544
ERC721K 73577 112544 209267 330375
OpenZeppelin Consecutive 20853 20958 20875 20897
OpenZeppelin Enumerable 47518 52082 52016 52033
OpenZeppelin 18274 18379 18296 18318
Solady 18170 18275 18192 18214
Solmate 18251 18356 18273 18295

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 53070 90127 178661 289389
ERC721B 278265 258559 170813 44091
ERC721K 56796 95680 192420 313484
OpenZeppelin Consecutive 28885 28907 28841 28819
OpenZeppelin Enumerable 79689 67411 67345 67323
OpenZeppelin 28561 28583 28517 28495
Solady 28032 28054 27988 27966
Solmate 28457 28479 28413 28391

To a wallet that owns no token from the collection

Implementation 1 10 50 100
ERC721A 70148 107205 195739 306511
ERC721B 278243 258537 170791 44113
ERC721K 73874 112758 209498 330606
OpenZeppelin Consecutive 45963 45985 45919 45941
OpenZeppelin Enumerable 76867 79689 79623 79645
OpenZeppelin 45639 45661 45595 45617
Solady 45110 45132 45066 45088
Solmate 45535 45557 45491 45513

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 55902 92893 181515 292181
ERC721B 281144 261372 173714 46930
ERC721K 59665 98483 195311 316314
OpenZeppelin Consecutive 31717 31673 31695 31611
OpenZeppelin Enumerable 82540 70196 70218 70134
OpenZeppelin 31390 31346 31368 31284
Solady 30704 30660 30682 30598
Solmate 31182 31138 31160 31076

To a wallet that owns no token from the collection

Implementation 1 10 50 100
ERC721A 72980 109971 198593 309387
ERC721B 281122 261350 173692 47036
ERC721K 76743 115561 212389 333520
OpenZeppelin Consecutive 48795 48751 48773 48817
OpenZeppelin Enumerable 79718 82474 82496 82540
OpenZeppelin 48468 48424 48446 48490
Solady 47782 47738 47760 47804
Solmate 48260 48216 48238 48282

setApprovalForAll

How much gas for setApprovalForAll?

Implementation --
ERC721A 32838
ERC721B 32903
ERC721K 32833
OpenZeppelin Consecutive 32883
OpenZeppelin Enumerable 32875
OpenZeppelin 32809
Solady 32684
Solmate 32797

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 37082 57061 145639 256345
ERC721B 254445 234761 147059 37415
ERC721K 37470 59276 156060 277102
OpenZeppelin Consecutive 35130 35174 35152 35108
OpenZeppelin Enumerable 34979 35023 35001 34957
OpenZeppelin 34979 35023 35001 34957
Solady 34748 34792 34770 34726
Solmate 34869 34913 34891 34847

View methods

balanceOf

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

Implementation 1 10 50 100
ERC721A 7958 7897 7875 7853
ERC721B 1648560 1648742 1649800 1651128
ERC721K 7977 7916 7894 7872
OpenZeppelin Consecutive 7930 7869 7847 7825
OpenZeppelin Enumerable 8027 7966 7944 7922
OpenZeppelin 7937 7876 7854 7832
Solady 7918 7857 7835 7813
Solmate 7926 7865 7843 7821

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 10057 29970 118636 229268
ERC721B 227405 207655 120041 10323
ERC721K 10440 32180 129052 250021
OpenZeppelin Consecutive 8001 7979 8045 7927
OpenZeppelin Enumerable 7949 7927 7993 7875
OpenZeppelin 7883 7861 7927 7809
Solady 7883 7861 7927 7809
Solmate 7846 7824 7890 7772

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 10035 30014 118636 229298
ERC721B 227383 207699 120041 10353
ERC721K 10418 32224 129052 250051
OpenZeppelin Consecutive 7979 8023 8045 7957
OpenZeppelin Enumerable 7927 7971 7993 7905
OpenZeppelin 7861 7905 7927 7839
Solady 7861 7905 7927 7839
Solmate 7824 7868 7890 7802

isApprovedForAll

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

Implementation --
ERC721A 8215
ERC721B 8259
ERC721K 8196
OpenZeppelin Consecutive 8193
OpenZeppelin Enumerable 8240
OpenZeppelin 8174
Solady 8070
Solmate 8168