{"id":13410219,"url":"https://github.com/auditless/cairo-template","last_synced_at":"2025-03-14T15:32:03.081Z","repository":{"id":116307536,"uuid":"604675624","full_name":"auditless/cairo-template","owner":"auditless","description":"A minimal template for building smart contracts with Cairo 1.0","archived":false,"fork":false,"pushed_at":"2023-06-01T08:46:55.000Z","size":33,"stargazers_count":88,"open_issues_count":0,"forks_count":12,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-31T20:41:16.386Z","etag":null,"topics":["cairo-lang","starknet","template"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auditless.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":"2023-02-21T15:02:25.000Z","updated_at":"2024-01-05T14:21:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"aec61e3a-7f26-4aed-a9dd-1334533cc963","html_url":"https://github.com/auditless/cairo-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auditless%2Fcairo-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auditless%2Fcairo-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auditless%2Fcairo-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auditless%2Fcairo-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auditless","download_url":"https://codeload.github.com/auditless/cairo-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243600698,"owners_count":20317317,"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-lang","starknet","template"],"created_at":"2024-07-30T20:01:05.606Z","updated_at":"2025-03-14T15:32:03.075Z","avatar_url":"https://github.com/auditless.png","language":"Rust","funding_links":[],"categories":["Templates"],"sub_categories":[],"readme":"# Minimal Cairo 1.0 Template  ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/auditless/cairo-template/blob/main/LICENSE) \u003ca href=\"https://github.com/auditless/cairo-template/actions/workflows/test.yaml\"\u003e \u003cimg src=\"https://github.com/auditless/cairo-template/actions/workflows/test.yaml/badge.svg?event=push\" alt=\"CI Badge\"/\u003e \u003c/a\u003e\n\n[Built with **`auditless/cairo-template`**](https://github.com/auditless/cairo-template)\n\nA minimal template for building smart contracts with Cairo 1.0\nusing the [alexandria](https://github.com/keep-starknet-strange/alexandria) project defaults.\n\n## How it works\n\n- No submodules, forks or other heavy machinery\n- Uses [`protostar`](https://github.com/software-mansion/protostar) toolchain for running tests\n- Built as a [Scarb](https://github.com/software-mansion/scarb) package for reusability and uses Scarb dependencies for libraries\n- Has reproducible builds using GitHub Actions\n- Uses Scarb scripts natively for custom commands\n- Includes advanced debugging views like the Sierra intermediate representation\n\n## Installing dependencies\n\n### Step 1: Install the Cairo package manager Scarb\n\nFollow the installation guide in [Scarb's documentation](https://docs.swmansion.com/scarb).\n\n### Step 2: Install the Protostar toolchain\n\nFollow the installation guide in [Protostar's Repository](https://github.com/software-mansion/protostar).\n\n\n### Step 3: Install Cairo 1.0 (guide by [Abdel](https://github.com/abdelhamidbakhta))\n\n**NOTE: By installing Scarb, you already have an accompanying Cairo 1.0 version which can be viewed by running `$ scarb --version`. This installation step is included to allow you maintain an independent version of Cairo. This step will also prove useful when setting up the language server in [Step 5](#step-5-setup-language-server).**\n\nIf you are on an x86 Linux system and able to use the release binary,\nyou can download Cairo here https://github.com/starkware-libs/cairo/releases.\n\nFor everyone, else, we recommend compiling Cairo from source like so:\n\n```bash\n# Install stable Rust\n$ rustup override set stable \u0026\u0026 rustup update\n\n# Clone the Cairo compiler in $HOME/Bin\n$ cd ~/Bin \u0026\u0026 git clone git@github.com:starkware-libs/cairo.git \u0026\u0026 cd cairo\n\n# OPTIONAL/RECOMMENDED: If you want to install a specific version of the compiler\n# Fetch all tags (versions)\ngit fetch --all --tags\n# View tags (you can also do this in the cairo compiler repository)\ngit describe --tags `git rev-list --tags`\n# Checkout the version you want\ngit checkout tags/v1.0.0-alpha.6\n\n# Generate release binaries\n$ cargo build --all --release\n```\n\n**NOTE: Keeping Cairo up to date**\n\nNow that your Cairo compiler is in a cloned repository, all you will need to do\nis pull the latest changes and rebuild as follows:\n\n```bash\n$ cd ~/Bin/cairo \u0026\u0026 git fetch \u0026\u0026 git pull \u0026\u0026 cargo build --all --release\n```\n\n### Step 4: Add Cairo 1.0 executables to your path\n\n```bash\nexport PATH=\"$HOME/Bin/cairo/target/release:$PATH\"\n```\n\n**NOTE: If installing from a Linux binary, adapt the destination path accordingly.**\n\nThis will make available several binaries. The one we use is called `cairo-test`.\n\n### Step 5: Setup Language Server\n\n#### VS Code Extension\n\n- Disable previous Cairo 0.x extension\n- Install the Cairo 1 extension for proper syntax highlighting and code navigation.\nJust follow the steps indicated [here](https://github.com/starkware-libs/cairo/blob/main/vscode-cairo/README.md).\n\n#### Cairo Language Server\n\nThe Cairo Language Server now comes bundled with the Scarb package manger distribution.\nYou can make sure it is available in your system by running `$ scarb commands`.\nThe output should include a line starting with `cairo-language-server`.\n\n## How to use this template\n\nFirst you will need to clone the repository or click the `Use this template` button\nat the top of the page to create a new repository based on the template.\n\nNext, you will want to update the configuration file with the name of your project:\n\n```\n└── .Scarb.toml\n```\nAlso, if you're using a different `protostar` version, you'll want to update the version in the configuration file as well\n```\n└── .protostar.toml\n```\n## Working with your project\n\nThe Cairo template currently supports building and testing contracts.\n\n### Build\n\nBuild the contracts.\n\n```bash\n$ scarb build\n```\n\n### Test\n\nRun the tests in `src/test`:\n\n```bash\n$ scarb run test\n```\n\n### Format\n\nFormat the Cairo source code (using Scarb):\n\n```bash\n$ scarb fmt\n```\n\n### Sierra and Casm (advanced)\nThe Sierra output of your cairo code is automatically built by scarb when you run `$ scarb build`.\n\nTo change this behaviour, add the following code to the `[lib]` section of your `Scarb.toml` configuration file\n```\n    [lib]\n    sierra = false\n```\nSimilarly, to generate casm (Cairo assembly), add the following code to the `[lib]` section of your `Scarb.toml` configuration file\n```\n    [lib]\n    casm = true\n```\n\n## Thanks to\n\n- The [alexandria](https://github.com/keep-starknet-strange/alexandria) team for coming up with\nthis configuration and especially [Abdel](https://github.com/abdelhamidbakhta) for helping me with Cairo 1.0 installation\n- [Paul Berg](https://github.com/PaulRBerg) and the [foundry-template](https://github.com/paulrberg/foundry-template) project which served as inspiration\n- Last but not least, the StarkWare team for building the first smart contract language that is a joy to use\n\n## Other templates\n\n- [ArgentX template](https://github.com/argentlabs/starknet-build/tree/main/cairo1.0) is built as a fork of the compiler\n- [Eni's cairo1-template](https://github.com/msaug/cairo1-template) uses git submodules for installation\n- [Shramee's Starklings](https://github.com/shramee/starklings-cairo1) use the cairo1 crates as libraries and builds its own framework\n\n## License\n\n[MIT](https://github.com/auditless/cairo-template/blob/main/LICENSE) © [Auditless Limited](https://www.auditless.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauditless%2Fcairo-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauditless%2Fcairo-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauditless%2Fcairo-template/lists"}