Skip to content

An ERC-721 implementation using Solidity inline-assembly, competitive in gas consumption with Solady.

Notifications You must be signed in to change notification settings

nkrishang/yul-erc721

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ERC-721 YUL implementation

src/ERC721Yul.sol is an ERC-721 smart contract implemented almost entire inline assembly. It uses a straightforward storage layout and is gas competitive with optimized ERC-721 implementations such as solady and solmate.

src/ERC721.yul is a pure YUL implementation of the same, and is also tested and benchmarked using forge.

Benchmarks

The benchmark file is the test/Benchmark.t.sol forge test file. Actual blockchain transactions may yield different results.

Test YUL Inline Assembly SOLADY SOLMATE
approve 31730 32299 32442 32458
balanceOf 7534 7760 7797 7899
burn 11636 11553 12152 11969
mint 34798 35206 35293 35565
ownerOf 7588 7657 7792 7801
safeMint 106623 106899 107321 108844
safeTransferFrom 111889 113786 113847 116468
setApprovalForAll 29437 29974 29992 30124
transferFrom 37215 38202 38196 38695

If you know how to improve on this implementation, please make a PR. I'd love to learn.

Usage

Build

$ forge build

Test

$ forge test

Benchmark

$ make benchmark

About

An ERC-721 implementation using Solidity inline-assembly, competitive in gas consumption with Solady.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published