{"id":13544044,"url":"https://github.com/cairoeth/rustmate","last_synced_at":"2025-03-25T12:32:44.862Z","repository":{"id":216713533,"uuid":"702470188","full_name":"cairoeth/rustmate","owner":"cairoeth","description":"🦀 Blazing fast, modern, and optimized Rust building blocks for smart contract development using Stylus.","archived":false,"fork":false,"pushed_at":"2024-01-12T20:48:07.000Z","size":134,"stargazers_count":50,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-20T05:06:03.967Z","etag":null,"topics":["alloy","arbitrum","ethereum","rust","stylus"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cairoeth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-10-09T11:31:46.000Z","updated_at":"2025-02-16T05:21:28.000Z","dependencies_parsed_at":"2024-01-12T07:06:16.206Z","dependency_job_id":"56856bbe-1b0e-416f-a676-966f806205a7","html_url":"https://github.com/cairoeth/rustmate","commit_stats":null,"previous_names":["cairoeth/rustmate"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cairoeth%2Frustmate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cairoeth%2Frustmate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cairoeth%2Frustmate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cairoeth%2Frustmate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cairoeth","download_url":"https://codeload.github.com/cairoeth/rustmate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245462868,"owners_count":20619573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alloy","arbitrum","ethereum","rust","stylus"],"created_at":"2024-08-01T11:00:41.252Z","updated_at":"2025-03-25T12:32:44.481Z","avatar_url":"https://github.com/cairoeth.png","language":"Rust","funding_links":[],"categories":["Libraries"],"sub_categories":["Talks \u0026 Presentations"],"readme":"# 🦀 rustmate\n\n[![Run benchmarks](https://github.com/cairoeth/rustmate/actions/workflows/benchmark.yml/badge.svg)](https://github.com/cairoeth/rustmate/actions/workflows/benchmark.yml)\n[![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)\n\n**Blazing fast**, **modern**, and **optimized** Rust building blocks for smart contract development using Stylus. \n\n\u003e This is **experimental software** and is provided on an \"as is\" and \"as available\" basis. We **do not give any warranties** and **will not be liable for any losses** incurred through any use of this code base.\n\n## 📜 Contracts\n\n```ml\nauth\n├─ Owned — \"Simple single owner authorization\"\n├─ Auth — \"Flexible and updatable auth pattern\"\nmixins\n├─ ERC4626 — \"Minimal ERC4626 tokenized Vault implementation\"\ntokens\n├─ WETH — \"Minimalist and modern Wrapped Ether implementation\"\n├─ ERC20 — \"Modern and gas efficient ERC20 + EIP-2612 implementation\"\n├─ ERC721 — \"Modern, minimalist, and gas efficient ERC721 implementation\"\n├─ ERC1155 — \"Minimalist and gas efficient standard ERC1155 implementation\"\n├─ ERC6909 — \"Minimalist and gas efficient standard ERC6909 implementation\"\nutils\n├─ CREATE3 — \"Deploy to deterministic addresses without an initcode factor\"\n├─ Bytes32Address — \"Library for converting between addresses and bytes32 values\"\n```\n\n## 🔧 How to use\n\nFirst, install the [Stylus SDK for Rust](https://docs.arbitrum.io/stylus/stylus-quickstart) and create a new project:\n    \n```bash\ncargo stylus new my-project --minimal\n```\n\nThen, install `rustmate`:\n\n```bash\ncargo add rustmate\n```\n\nImport the contracts you want to use:\n\n```rust\nuse rustmate::tokens::erc20::{ERC20, ERC20Params};\n```\n\n## ✅ Gas benchmarks\n\n### 🧪 Results\n\n\u003cdetails\u003e\u003csummary\u003eERC20\u003c/summary\u003e\n\n|    Function    | Rustmate | Solmate | OpenZeppelin Contracts 5.0 |\n|:--------------:|:--------:|:-------:|:--------------------------:|\n|     name()     |   23043  |  24504  |            24514           |\n|    symbol()    |   22974  |  24571  |            24535           |\n|   decimals()   |   22726  |  21512  |            21520           |\n|  totalSupply() |   25617  |  23562  |            23570           |\n|   balanceOf()  |   26851  |  24292  |            24296           |\n|   allowance()  |   28263  |  25011  |            25066           |\n|    nonces()    |   26835  |  24302  |             N/A            |\n|    approve()   |   50557  |  46683  |            46902           |\n|   transfer()   |   74234  |  47133  |            27454           |\n| transferFrom() |   60116  |  28993  |            29202           |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eERC721\u003c/summary\u003e\n\n|       Function      | Rustmate | Solmate | OpenZeppelin Contracts 5.0 |\n|:-------------------:|:--------:|:-------:|:--------------------------:|\n|        name()       |   23286  |  24548  |            24556           |\n|       symbol()      |   23225  |  24548  |            24556           |\n|      ownerOf()      |   24212  |  24212  |            24308           |\n|     balanceOf()     |   27094  |  24352  |            24352           |\n|    getApproved()    |   26749  |  24132  |            26545           |\n|  isApprovedForAll() |   28447  |  25046  |            25104           |\n|      tokenURI()     |   24293  |  23420  |            23420           |\n|      approve()      |   48639  |  48693  |            49043           |\n| setApprovalForAll() |   51279  |  46561  |            46669           |\n|    transferFrom()   |   32777  |  32437  |            32947           |\n|  safeTransferFrom() |   32781  |  32643  |            31264           |\n|  safeTransferFrom() |   33146  |  33140  |            34139           |\n| supportsInterface() |   21983  |  21983  |            21960           |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eERC1155\u003c/summary\u003e\n\n|         Function        | Rustmate | Solmate | OpenZeppelin Contracts 5.0 |\n|:-----------------------:|:--------:|:-------:|:--------------------------:|\n|       balanceOf()       |   28390  |  24631  |            24675           |\n|    isApprovedForAll()   |   28474  |  25022  |            25081           |\n|          uri()          |   24346  |  22291  |            24984           |\n|   setApprovalForAll()   |   51321  |  46581  |            46690           |\n|    safeTransferFrom()   |   30167  |  29793  |            31672           |\n| safeBatchTransferFrom() |   33192  |  32054  |            33363           |\n|     balanceOfBatch()    |   25094  |  22961  |            23735           |\n|   supportsInterface()   |   22006  |  22006  |            22058           |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eERC6909\u003c/summary\u003e\n\n|       Function      | Rustmate | Solmate | OpenZeppelin Contracts 5.0 |\n|:-------------------:|:--------:|:-------:|:--------------------------:|\n|      transfer()     |   77615  |  28656  |             N/A            |\n|    transferFrom()   |   68799  |  29356  |             N/A            |\n|      approve()      |   52110  |  47430  |             N/A            |\n|    setOperator()    |   51152  |  46750  |             N/A            |\n| supportsInterface() |   22376  |  21962  |             N/A            |\n\n\u003c/details\u003e\n\n### 👷 How to replicate\n\nInstall [Python](https://www.python.org/downloads/) and [Rust](https://www.rust-lang.org/tools/install), and then install the Stylus CLI tool with Cargo:\n\n```bash\nRUSTFLAGS=\"-C link-args=-rdynamic\" cargo install --force cargo-stylus\n```\n\nAdd the `wasm32-unknown-unknown` build target to your Rust compiler:\n\n```bash\nrustup target add wasm32-unknown-unknown\n```\n\nThen, clone the repository:\n\n```bash\ngit clone https://github.com/cairoeth/rustmate \u0026\u0026 cd rustmate\n```\n\nClone Arbitrum Nitro node that supports Stylus:\n\n```bash\ngit clone -b stylus --recurse-submodules https://github.com/OffchainLabs/nitro-testnode.git \u0026\u0026 cd nitro-testnode\n```\n\nRun the node and wait for it to start up:\n\n```bash\n./test-node.bash --init --detach\n```\n\nOpen another terminal window and fund the deployer address:\n\n```bash\n./test-node.bash script send-l2 --to address_0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 --ethamount 100\n```\n\nNavigate back to `rustmate` and select a benchmark to run. For example, ERC20:\n\n```bash\ncd ../benchmark/erc20_benchmark \u0026\u0026 python snapshot.py\n```\n\nCheck the results in the terminal or in the `.gas-snapshot` file.\n\n## 🙏🏼 Acknowledgements\n\nThis repository is inspired by or directly modified from many sources, primarily:\n\n- [solmate](https://github.com/transmissions11/solmate)\n- [OpenZeppelin Contracts](https://github.com/OpenZeppelin/openzeppelin-contracts)\n- [snekmate](https://github.com/pcaversaccio/snekmate)\n- [stylus-sdk-rs](https://github.com/OffchainLabs/stylus-sdk-rs)\n\n## 🫡 Contributing\n\nCheck out the [Contribution Guidelines](./CONTRIBUTING.md)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcairoeth%2Frustmate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcairoeth%2Frustmate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcairoeth%2Frustmate/lists"}