{"id":13410425,"url":"https://github.com/starknet-edu/deploy-cairo1-demo","last_synced_at":"2025-03-14T16:32:10.452Z","repository":{"id":239397855,"uuid":"617381504","full_name":"starknet-edu/deploy-cairo1-demo","owner":"starknet-edu","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-30T09:39:49.000Z","size":4,"stargazers_count":48,"open_issues_count":5,"forks_count":23,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T20:42:38.611Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Cairo","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/starknet-edu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-03-22T09:20:25.000Z","updated_at":"2024-05-14T21:02:09.000Z","dependencies_parsed_at":"2024-05-12T05:51:22.812Z","dependency_job_id":"1a2a9642-ecfa-49a6-a069-e3d98663d690","html_url":"https://github.com/starknet-edu/deploy-cairo1-demo","commit_stats":null,"previous_names":["starknet-edu/deploy-cairo1-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starknet-edu%2Fdeploy-cairo1-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starknet-edu%2Fdeploy-cairo1-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starknet-edu%2Fdeploy-cairo1-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starknet-edu%2Fdeploy-cairo1-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/starknet-edu","download_url":"https://codeload.github.com/starknet-edu/deploy-cairo1-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243610202,"owners_count":20318920,"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":[],"created_at":"2024-07-30T20:01:06.815Z","updated_at":"2025-03-14T16:32:10.118Z","avatar_url":"https://github.com/starknet-edu.png","language":"Cairo","funding_links":[],"categories":["Tutorials"],"sub_categories":[],"readme":"# Deploying your first Cairo 1 contract to Starknet\nWith [version 0.11](https://starkware.medium.com/starknet-alpha-v0-11-0-the-transition-to-cairo-1-0-begins-30442d494515) rolling out on Starknet, you can now deploy your first Cairo 1 contracts on Starknet! Fantastic!\n\n... But how ser?\n\nHere is a very rough guide, before we get our doc in order\n\n## The flow\nYou will need to:\n- Clone the Cairo repository (the tool to compile your Cairo 1 contract) at a specific height\n- Install the latest version of Cairo-lang (the tool to interact with Starknet)\n- Compile your contract from Cairo to Sierra, using cairo \n- Declare your Sierra contract, using cairo-lang\n- Deploy your contract, using cairo-lang\n- Brag to your friends, using Twitter\n\n## Clone this repo\n```bash\ngit clone https://github.com/starknet-edu/deploy-cairo1-demo\ncd deploy-cairo1-demo\n```\n\n## Installing the Cairo one compiler\nIf you're installing Cairo for the first time:\n```bash\ngit clone https://github.com/starkware-libs/cairo/\ncd cairo\ngit checkout 9c190561ce1e8323665857f1a77082925c817b4c\ncargo build --all --release\n```\n\nIf you already have Cairo installed:\n```bash\ncd cairo\ngit fetch \u0026\u0026 git pull\ngit checkout 9c190561ce1e8323665857f1a77082925c817b4c\ncargo build --all --release\n```\n\nAt this point you have Cairo installed in this repository. \n\n## Installing Cairo-lang\nGo back to the root folder of the repo\n```bash\ncd ..\n```\nSet up a python virtual environment\n```bash\npython3.9 -m venv ~/cairo_venv_v11\nsource ~/cairo_venv_v11/bin/activate\n```\nIf you had cairo-lang installed previously, uninstall it\n```bash\npip3 uninstall cairo-lang\n```\nInstall Cairo lang\n```bash\npip3 install ecdsa fastecdsa sympy\npip3 install cairo-lang\n```\nCheck that you have it installed correctly\n```bash\nstarknet --version\n```\n\n## Compile your contract using Cairo\nYou can use [this smol demo contract](hello_starknet.cairo) to complete this test. It's a very basic event logger.\n\nFrom your terminal, in the folder you installed Cairo in\n```bash\ncd cairo\ncargo run --bin starknet-compile -- ../hello_starknet.cairo ../hello_starknet.json --replace-ids\t\n```\nCongratulations, you have compiled your contracts from Cairo to Sierra!\n\n## Declare your contract using Cairo-lang\n### Setting environment variables\n```bash\nexport STARKNET_NETWORK=alpha-goerli\nexport STARKNET_WALLET=starkware.starknet.wallets.open_zeppelin.OpenZeppelinAccount\n```\n\n### Setting a new account for the tutorial\n\nYou need to make sure your starknet CLI is set up with a proper account contract, and funds. For safety, I'll create a new one just for this tutorial.\n```bash\nstarknet new_account --account version_11\n```\n- You should get your expected contract address\n- Send 0.1 ETH to it\n- Monitor the transfer transaction. Once it has passed \"pending\", proceed\n```bash\nstarknet deploy_account --account version_11\n```\nMonitor the deploy transaction. Once it has passed \"pending\", proceed\n\n### Declaring the contract\nGo back to the root folder of the tutorial then try to declare\n```bash\ncd ..\nstarknet declare --contract hello_starknet.json --account version_11\n```\nYou should receive your newly declared class hash!\n\n### Troubleshooting\nOk so here I had a problem. Using declare sent back:\n```bash\nError: OSError: [Errno 8] Exec format error: '~/cairo_venv_11/lib/python3.9/site-packages/starkware/starknet/compiler/v1/bin/starknet-sierra-compile'\n```\nThe reason is that cairo-lang needs to compile your sierra code, and it uses an imported rust binary 'starknet-sierra-compile' for that. But in my case, the imported binary was not built for my achitecture :-(.\n\nSo, simple: I took the 'starknet-sierra-compile' from the cairo repo, that I built locally, and replaced it in the python package. Here is a command that should work:\n\n```bash\ncp cairo/target/release/starknet-sierra-compile ~/cairo_venv_v11/lib/python3.9/site-packages/starkware/starknet/compiler/v1/bin/starknet-sierra-compile\n```\n\nThen try again declaring. It should work!\n\n## Deploy your contract using Cairo-lang\nAt this point you are back in the flow you are used to. Using the class hash you received earlier:\n```bash\nstarknet deploy --class_hash \u003cclass_hash\u003e --account version_11\n```\nMonitor your transaction. If it fails because of fee estimation, retry. Once your transaction is accepted_on_l2.... Congratulations! You've deployed your first Cairo 1 contract!\n\n## Bragging on Twitter\nDon't forget to brag! Post your deployed contract [here](https://twitter.com/henrlihenrli/status/1638468939939282945)\n\nAnd don't forget to add cool functionnalities to your contract.\nThe Starknet edu team will release soon the Cairo 1 version of [Cairo-101](https://github.com/starknet-edu/starknet-cairo-101). In the meanwhile, you can get ideas of what to do with Cairo 1 with [Starklings-cairo1](https://github.com/shramee/starklings-cairo1)\n\n## Do you want to learn more?\nIf you are interested in \n- Learning how to develop cool stuff on Starknet\n- How Starknet works\n- What Cairo is\n- How Stark proofs work\nYou should join Basecamp, our free 6 weeks training program for aspiring Starknet devs. The next two cohorts start in April and you register [here](https://forms.reform.app/starkware/starknet-basecamp-registration-starting-jan-4th-copy-2/itvk4e) for a cohort in English, and [aqui](https://forms.reform.app/starkware/starknet-basecamp-registration-starting-apr-11th-copy/itvk4e) para una cohort en Español.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarknet-edu%2Fdeploy-cairo1-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarknet-edu%2Fdeploy-cairo1-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarknet-edu%2Fdeploy-cairo1-demo/lists"}