Skip to content

feat: add ERC-6909 Token and Supply extension#777

Merged
bidzyyys merged 60 commits into
OpenZeppelin:mainfrom
onurinanc:feature/ERC6909
Dec 3, 2025
Merged

feat: add ERC-6909 Token and Supply extension#777
bidzyyys merged 60 commits into
OpenZeppelin:mainfrom
onurinanc:feature/ERC6909

Conversation

@onurinanc

@onurinanc onurinanc commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

PR Checklist

  • Tests
  • Documentation
  • Changelog

ERC6909 Implementation in rust-contracts-stylus

Summary

This PR implements the ERC-6909 token and Supply extension in Rust for Arbitrum Stylus.

The following implementation is provided in this PR:

  • ERC-6909 + unit tests with motsu
  • Supply Extension + unit tests with motsu
  • Example usage of ERC-6909 and Supply Extension
  • Integration Tests for ERC-6909 and Supply Extension
  • Benchmark for both ERC6909 and Supply Extension

Comments

Integration tests and the benchmarks inside rust-contracts-stylus, which use nitro-testnode, didn't work with the M3 Pro Chip (would be an issue related to Docker). To solve the problem, firstly, [nitro-devnode] is tried to use. However, I observed that it is not suitable for the e2e::test workflow. So, an LTS Ubuntu machine is rented on AWS to run the integration tests and the benchmark.

For the Supply Extension implementation, Deref traits are implemented. Using Deref allows direct access to Erc6909 methods, improving readability and maintainability. However, deferencing operations might increase the gas. Designing Supply Token Extension in this way increases the abstraction and makes it easy to use for users who would like to use the Supply Extension with ERC-6909 Token Contract.

Future Improvements

Currently, this PR does not include other ERC-6909 Extensions, specifically ContentURI and Metadata. Their example usage and the benchmarks should be added to the repository.

The unit tests that differentiate the id should be added.

Benchmark

Benchmarks for ERC-6909 can be seen as follows:

| Contract::function                                                        | WASM Opt & Cached | Cached | Not Cached |
| ------------------------------------------------------------------------- | ----------------- | ------ | ---------- |
| Erc6909::mint(address,uint256,uint256)                                    |             27925 |  29307 |      45089 |
| Erc6909::balanceOf(address,uint256)                                       |              5101 |   6448 |      22230 |
| Erc6909::allowance(address,address,uint256)                               |              5875 |   7228 |      23010 |
| Erc6909::isOperator(address,address)                                      |              5322 |   6666 |      22448 |
| Erc6909::setOperator(address,bool)                                        |             27045 |  28433 |      44215 |
| Erc6909::transfer(address,uint256,uint256)                                |             34364 |  35786 |      51568 |
| Erc6909::approve(address,uint256,uint256)                                 |             27939 |  29332 |      45114 |
| Erc6909::transferFrom(address,address,uint256,uint256)                    |             20503 |  21943 |      37725 |
| Erc6909::burn(address,uint256,uint256)                                    |             11495 |  12893 |      28675 |

@netlify

netlify Bot commented Aug 7, 2025

Copy link
Copy Markdown

Deploy Preview for contracts-stylus canceled.

Name Link
🔨 Latest commit 75c900a
🔍 Latest deploy log https://app.netlify.com/projects/contracts-stylus/deploys/69300fc4c0c07000081b90de

@bidzyyys bidzyyys changed the title Feature/erc6909 feat: add ERC-6909 Token and Supply extension Aug 7, 2025
@bidzyyys bidzyyys linked an issue Aug 7, 2025 that may be closed by this pull request
1 task
@codecov

codecov Bot commented Nov 19, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.28717% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.68%. Comparing base (b648011) to head (75c900a).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
contracts/src/token/erc6909/mod.rs 99.13% 4 Missing ⚠️
...racts/src/token/erc6909/extensions/token_supply.rs 99.42% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #777      +/-   ##
==========================================
+ Coverage   95.46%   95.68%   +0.22%     
==========================================
  Files          89       91       +2     
  Lines       15814    16796     +982     
==========================================
+ Hits        15097    16072     +975     
- Misses        717      724       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@qalisander qalisander left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@onurinanc great job and lgtm!

@0xNeshi 0xNeshi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Comment thread docs/modules/ROOT/pages/erc6909.adoc
Comment thread contracts/src/token/erc6909/extensions/token_supply.rs Outdated
Comment thread contracts/src/token/erc6909/mod.rs Outdated
Comment thread contracts/src/token/erc6909/mod.rs Outdated
@0xNeshi
0xNeshi self-requested a review November 26, 2025 09:26
Comment thread contracts/src/token/erc6909/mod.rs Outdated
Comment thread contracts/src/token/erc6909/mod.rs Outdated
Comment thread contracts/src/token/erc6909/mod.rs Outdated
Comment thread contracts/src/token/erc6909/mod.rs Outdated
Co-authored-by: Nenad <xinef.it@gmail.com>

@bidzyyys bidzyyys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass.

Comment thread CHANGELOG.md Outdated
Comment thread docs/modules/ROOT/pages/erc6909-supply.adoc Outdated
Comment thread docs/modules/ROOT/pages/erc6909.adoc Outdated
Comment thread docs/modules/ROOT/pages/erc6909.adoc Outdated

@bidzyyys bidzyyys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second pass.

Comment thread contracts/src/token/erc6909/extensions/token_supply.rs Outdated
Comment thread contracts/src/token/erc6909/extensions/token_supply.rs Outdated
Comment thread contracts/src/token/erc6909/extensions/token_supply.rs Outdated
Comment thread contracts/src/token/erc6909/extensions/token_supply.rs
Comment thread examples/erc6909-supply/tests/erc6909-supply.rs
Comment thread CHANGELOG.md Outdated
Comment thread examples/erc6909/tests/erc6909.rs

@bidzyyys bidzyyys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost ready to merge.

Comment thread contracts/src/token/erc6909/mod.rs
Comment thread contracts/src/token/erc6909/mod.rs Outdated
Comment thread contracts/src/token/erc6909/mod.rs
Comment thread contracts/src/token/erc6909/mod.rs Outdated
Comment thread contracts/src/token/erc6909/mod.rs Outdated
Comment thread contracts/src/token/erc6909/mod.rs Outdated
@bidzyyys
bidzyyys merged commit d9883b3 into OpenZeppelin:main Dec 3, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add ERC-6909 Supply Extension [Feature]: Implement ERC-6909 Token

4 participants