{"id":13632409,"url":"https://github.com/lambdaclass/starknet_in_rust","last_synced_at":"2025-10-24T00:58:46.067Z","repository":{"id":64880816,"uuid":"574632352","full_name":"lambdaclass/starknet_in_rust","owner":"lambdaclass","description":"A Rust implementation of Starknet execution logic","archived":false,"fork":false,"pushed_at":"2024-04-17T01:22:41.000Z","size":5586,"stargazers_count":168,"open_issues_count":37,"forks_count":50,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-05-01T17:52:20.649Z","etag":null,"topics":["cairo","ethereum","rust","starknet"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lambdaclass.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-05T18:30:29.000Z","updated_at":"2024-06-05T11:30:06.777Z","dependencies_parsed_at":"2023-10-02T12:16:30.060Z","dependency_job_id":"b0c7cba5-969c-4dc6-bd91-16ea01db5db8","html_url":"https://github.com/lambdaclass/starknet_in_rust","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaclass%2Fstarknet_in_rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaclass%2Fstarknet_in_rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaclass%2Fstarknet_in_rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaclass%2Fstarknet_in_rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lambdaclass","download_url":"https://codeload.github.com/lambdaclass/starknet_in_rust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244056425,"owners_count":20390719,"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":["cairo","ethereum","rust","starknet"],"created_at":"2024-08-01T22:03:02.535Z","updated_at":"2025-10-24T00:58:45.994Z","avatar_url":"https://github.com/lambdaclass.png","language":"Rust","funding_links":[],"categories":["Rust","Additional developer resources","Layer 2"],"sub_categories":["Starknet"],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"./starknet_logo.svg\" width=\"150\"/\u003e\n\n### 🦀 Starknet in Rust 🦀\n\nStarknet transaction execution library in Rust, featuring [⚡cairo-vm⚡](https://github.com/lambdaclass/cairo-vm)\n\n[Report Bug](https://github.com/lambdaclass/starknet_in_rust/issues/new?labels=bug\u0026title=bug%3A+) · [Request Feature](https://github.com/lambdaclass/starknet_in_rust/issues/new?labels=enhancement\u0026title=feat%3A+)\n\n[![codecov](https://img.shields.io/codecov/c/github/lambdaclass/starknet_in_rust)](https://codecov.io/gh/lambdaclass/starknet_in_rust)\n[![license](https://img.shields.io/github/license/lambdaclass/starknet_in_rust)](/LICENSE)\n[![pr-welcome]](#-contributing)\n[![Telegram Chat][tg-badge]][tg-url]\n\n[pr-welcome]: https://img.shields.io/static/v1?color=orange\u0026label=PRs\u0026style=flat\u0026message=welcome\n[tg-badge]: https://img.shields.io/endpoint?url=https%3A%2F%2Ftg.sumanjay.workers.dev%2FLambdaStarkNet%2F\u0026logo=telegram\u0026label=chat\u0026color=neon\n[tg-url]: https://t.me/LambdaStarkNet\n\n\u003c/div\u003e\n\n## Table of Contents\n- [Table of Contents](#table-of-contents)\n- [📦 Archival Notice](#️-archival-notice)\n- [📖 About](#-about)\n- [🌅 Getting Started](#-getting-started)\n  - [Dependencies](#dependencies)\n  - [Requirements](#requirements)\n  - [Installation](#installation)\n    - [How to manually install the script dependencies](#how-to-manually-install-the-script-dependencies)\n- [🚀 Usage](#-usage)\n  - [Running simple contracts](#running-simple-contracts)\n  - [Testing](#testing)\n  - [Profiling](#profiling)\n  - [Benchmarking](#benchmarking)\n- [🛠 Contributing](#-contributing)\n- [🌞 Related Projects](#-related-projects)\n- [📚 Documentation](#-documentation)\n  - [Starknet](#starknet)\n- [⚖️ License](#️-license)\n\n\n## 📦 Archival Notice\n\n**Starknet in Rust is now archived.**\n\nWe have decided to archive this repository. Starknet in Rust supports Starknet up to version 0.13.0. Maintaining and updating this project requires substantial effort, and with Blockifier already in production and consistently updated, we will no longer add support for newer Starknet versions. We prefer to focus our efforts on other Starknet projects that can provide greater value to the community. See: [Related Projects](#-related-projects)\n\nIf you were using Starknet in Rust, we recommend transitioning to [Blockifier](https://github.com/starkware-libs/blockifier).\n\n\n## 📖 About\n\n`starknet_in_rust` is an implementation of [Starknet](https://github.com/starkware-libs/cairo-lang/tree/master/src/starkware/starknet) in Rust.\nIt makes use of [cairo-vm](https://github.com/lambdaclass/cairo-vm), the Rust implementation of the Cairo virtual machine.\n\n## 🌅 Getting Started\n\n### Dependencies\n- Rust 1.74.1\n- A working installation of cairo-lang 0.12 (for compiling the cairo files)\n- [Optional, for testing purposes] Heaptrack\n\n### Requirements\n\nYou need to have a version of `Python 3` installed. If you don't have it, you can install it for Debian-based GNU/Linux distributions with:\n```shell\nsudo apt install python3.9\n```\nOn MacOS you can use Homebrew:\n```shell\nbrew install python@3.9\n```\nOptionally, for setting environment, you can install `pyenv` for MacOS:\n```shell\nbrew install pyenv\n```\n\n### Installation\n\nIf you run `make` on it's own it will print out the main targets and their description.\n\nRun the following make targets to have a working environment (if in Mac or if you encounter an error, see the subsection below):\n\n#### Linux (x86-64)\n```bash\n$ make deps\n$ make build\n```\n\n#### OSX (Apple Silicon)\n```bash\n$ make deps-macos\n$ make build\n```\n\nCheck the [Makefile](/Makefile) for additional targets.\n\n#### How to manually install the script dependencies\n\n`cairo-lang` requires the `gmp` library to build.\nYou can install it on Debian-based GNU/Linux distributions with:\n```shell\nsudo apt install -y libgmp3-dev\n```\n\nIn Mac you can use Homebrew:\n```shell\nbrew install gmp\n```\n\nIn Mac you'll also need to tell the script where to find the gmp lib:\n```shell\nexport CFLAGS=-I/opt/homebrew/opt/gmp/include LDFLAGS=-L/opt/homebrew/opt/gmp/lib\n```\n\n### Cairo Native support\n\nStarknet in Rust can be integrated with [Cairo Native](https://github.com/lambdaclass/cairo_native), which makes the execution of sierra programs possible through native machine code. To use it, the following needs to be setup:\n\n- LLVM `17` needs to be installed and the `MLIR_SYS_170_PREFIX` and `TABLEGEN_170_PREFIX` environment variable needs to point to said installation. In macOS, run\n  ```\n  brew install llvm@17\n  export MLIR_SYS_170_PREFIX=/opt/homebrew/opt/llvm@17\n  export LLVM_SYS_170_PREFIX=/opt/homebrew/opt/llvm@17\n  export TABLEGEN_170_PREFIX=/opt/homebrew/opt/llvm@17\n  ```\n  and you're set.\n\nAfterwards, compiling with the feature flag `cairo-native` will enable native execution. You can check out some example test code that uses it under `tests/cairo_native.rs`.\n\n#### Using ahead of time compilation with Native.\n\nCurrently cairo-native with AOT needs a runtime library in a known place. For this you need to compile the [cairo-native-runtime](https://github.com/lambdaclass/cairo_native/tree/main/runtime) crate and point the following environment variable to a folder containing the dynamic library. The path **must** be an absolute path.\n\n```bash\nCAIRO_NATIVE_RUNTIME_LIBDIR=/absolute/path/to/cairo-native/target/release\n```\n\nIf you don't do this you will get a linker error when using AOT.\n\n## 🚀 Usage\n\n### Running simple contracts\n\nYou can find a tutorial on running contracts [here](/examples/contract_execution/README.md).\n\n### Customization\n\n#### Contract class cache behavior\n\n`starknet_in_rust` supports caching contracts in memory. Caching the contracts is useful for\navoiding excessive RPC API usage and keeping the contract class deserialization overhead to the\nminimum. The project provides two builtin cache policies: null and permanent. The null cache behaves\nas if there was no cache at all. The permanent cache caches everything in memory forever.\n\nIn addition to those two, an example is provided that implements and uses an LRU cache policy.\nLong-running applications should ideally implement a cache algorithm suited to their needs or\nalternatively use our example's implementation to avoid spamming the API when using the null cache\nor blowing the memory usage when running with the permanent cache.\n\nCustomized cache policies may be used by implementing the `ContractClassCache` trait. Check out our\n[LRU cache example](examples/lru_cache/main.rs) for more details. Updating the cache requires\nmanually merging the local state cache into the shared cache manually. This can be done by calling\nthe `drain_private_contract_class_cache` on the `CachedState` instance.\n\n```rs\n// To use the null cache (aka. no cache at all), create the state as follows:\nlet cache = Arc::new(NullContractClassCache::default());\nlet state1 = CachedState::new(state_reader.clone(), cache.clone());\nlet state2 = CachedState::new(state_reader.clone(), cache.clone()); // Cache is reused.\n\n// Insert state usage here.\n\n// The null cache doesn't have any method to extend it since it has no data.\n```\n\n```rs\n// If the permanent cache is preferred, then use `PermanentContractClassCache` instead:\nlet cache = Arc::new(PermanentContractClassCache::default());\nlet state1 = CachedState::new(state_reader.clone(), cache.clone());\nlet state2 = CachedState::new(state_reader.clone(), cache.clone()); // Cache is reused.\n\n// Insert state usage here.\n\n// Extend the shared cache with the states' contracts after using them.\ncache.extend(state1.state.drain_private_contract_class_cache());\ncache.extend(state2.state.drain_private_contract_class_cache());\n```\n\n#### Logging configuration\n\nThis project uses the [`tracing`](https://crates.io/crates/tracing) crate as a library. Check out\nits documentation for more information.\n\n### Testing\n\n#### Logging configuration\n\nThis project uses the [`tracing`](https://crates.io/crates/tracing) crate as a library. Check out\nits documentation for more information.\n\n### Testing\n\nRun the following command:\n```bash\n$ make test\n```\nTake into account that some tests use the [RPC State Reader](#rpc-state-reader) so you need a full-node instance or an RPC provider that supports Starknet API version 0.6.0.\n\n### RPC State Reader\n\n[The RPC State Reader](/rpc_state_reader/) provides a way of reading the real Starknet State when using Starknet in Rust.\nSo you can re-execute an existing transaction in any of the Starknet networks in an easy way, just providing the transaction hash, the block number and the network in which the transaction was executed.\nEvery time it needs to read a storage value, a contract class or contract, it goes to an RPC to fetch them.\n\nRight now we are using it for internal testing but we plan to release it as a library soon.\n\n#### How to configure it\nIn order to use the RPC state reader add the endpoints to a full node instance or RPC provider supporting Starknet API version 0.5.0 in a `.env` file at root:\n\n```\nRPC_ENDPOINT_TESTNET={some endpoint}\nRPC_ENDPOINT_MAINNET={some endpoint}\n```\n\n### Profiling\n\nRun the following command:\n\n```bash\n$ make flamegraph\n```\n\nto generate a flamegraph with info of the execution of the main operations.\n\n### Benchmarking\n\nRead the 'bench_integration.py' file to identify which lines need to be commented out for accurate results. Comment out those lines and then run the following command:\n\n```bash\n$ make benchmark\n```\n\n## 🛠 Contributing\n\nThe open source community is a fantastic place for learning, inspiration, and creation, and this is all thanks to contributions from people like you. Your contributions are **greatly appreciated**.\n\nIf you have any suggestions for how to improve the project, please feel free to fork the repo and create a pull request, or [open an issue](https://github.com/lambdaclass/starknet_in_rust/issues/new?labels=enhancement\u0026title=feat%3A+) with the tag 'enhancement'.\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\nAnd don't forget to give the project a star! ⭐ Thank you again for your support.\n\n## 🌞 Related Projects\n\n- [cairo-vm](https://github.com/lambdaclass/cairo-vm): A fast implementation of the Cairo VM in Rust.\n- [cairo-native](https://github.com/lambdaclass/cairo_native): A compiler to convert Cairo's intermediate representation \"Sierra\" code to machine code via MLIR and LLVM.\n- [cairo-vm-py](https://github.com/lambdaclass/cairo-vm-py): Bindings for using cairo-vm from Python code.\n\n## 📚 Documentation\n\n### Starknet\n- [Starknet's Architecture Review](https://david-barreto.com/starknets-architecture-review/)\n- [Starknet State](https://docs.starknet.io/documentation/architecture_and_concepts/State/starknet-state/)\n- [Array Hashing](https://docs.starknet.io/documentation/architecture_and_concepts/Hashing/hash-functions/#array_hashing)\n\n## ⚖️ License\n\nThis project is licensed under the Apache 2.0 license.\n\nSee [LICENSE](/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdaclass%2Fstarknet_in_rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flambdaclass%2Fstarknet_in_rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdaclass%2Fstarknet_in_rust/lists"}