{"id":30113959,"url":"https://github.com/near/cargo-near","last_synced_at":"2026-04-09T01:00:35.947Z","repository":{"id":38837075,"uuid":"501306030","full_name":"near/cargo-near","owner":"near","description":"Cargo extension for building Rust smart contracts on NEAR","archived":false,"fork":false,"pushed_at":"2026-04-08T22:33:50.000Z","size":1829,"stargazers_count":66,"open_issues_count":29,"forks_count":24,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-04-09T00:29:47.952Z","etag":null,"topics":["hacktoberfest","rust"],"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/near.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-06-08T15:21:08.000Z","updated_at":"2026-04-08T22:25:55.000Z","dependencies_parsed_at":"2023-10-01T17:33:39.245Z","dependency_job_id":"654d6182-dac2-47a2-9435-c8ea99a6746b","html_url":"https://github.com/near/cargo-near","commit_stats":{"total_commits":61,"total_committers":3,"mean_commits":"20.333333333333332","dds":0.540983606557377,"last_synced_commit":"b3a245f6470c234860c63dbf4c88996320adae39"},"previous_names":[],"tags_count":70,"template":false,"template_full_name":null,"purl":"pkg:github/near/cargo-near","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/near%2Fcargo-near","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/near%2Fcargo-near/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/near%2Fcargo-near/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/near%2Fcargo-near/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/near","download_url":"https://codeload.github.com/near/cargo-near/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/near%2Fcargo-near/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31580507,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["hacktoberfest","rust"],"created_at":"2025-08-10T07:36:53.426Z","updated_at":"2026-04-09T01:00:35.819Z","avatar_url":"https://github.com/near.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable MD014 --\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n  \u003ch1\u003e\u003ccode\u003ecargo-near\u003c/code\u003e\u003c/h1\u003e\n\n  \u003cp\u003e\n    \u003cstrong\u003eCargo extension for building \u003ca href=\"https://github.com/near/near-sdk-rs\"\u003enear-sdk-rs\u003c/a\u003e smart contracts and \u003ca href=\"https://github.com/near/abi\"\u003eABI schemas\u003c/a\u003e on NEAR\u003c/strong\u003e\n  \u003c/p\u003e\n\n  \u003cp\u003e\n    \u003ca href=\"https://github.com/near/cargo-near/actions/workflows/test.yml?query=branch%3Amain\"\u003e\u003cimg src=\"https://github.com/near/cargo-near/actions/workflows/test.yml/badge.svg\" alt=\"Github CI Build\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/cargo-near\"\u003e\u003cimg src=\"https://img.shields.io/crates/v/cargo-near.svg?style=flat-square\" alt=\"Crates.io version\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/cargo-near\"\u003e\u003cimg src=\"https://img.shields.io/crates/d/cargo-near.svg?style=flat-square\" alt=\"Download\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/cargo-near-build\"\u003e\u003cimg src=\"https://img.shields.io/crates/v/cargo-near-build.svg?style=flat-square\" alt=\"Crates.io version\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://near.chat\"\u003e\u003cimg src=\"https://img.shields.io/discord/490367152054992913?style=flat-square\u0026label=discord\u0026color=lightgreen\" alt=\"Join the community on Discord\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://t.me/NEAR_Tools_Community_Group\"\u003e\u003cimg src=\"https://img.shields.io/badge/telegram-online-lightgreen?style=flat-square\" alt=\"Join the community on Telegram\" /\u003e\u003c/a\u003e\n\n  \u003c/p\u003e\n\n\u003c/div\u003e\n\n## Release notes\n\n**Release notes and unreleased changes can be found in the [CHANGELOG](https://github.com/near/cargo-near/blob/main/CHANGELOG.md)**\n\n## Github Codespaces template + [an online ide](https://docs.github.com/en/codespaces/reference/using-the-vs-code-command-palette-in-codespaces)\n\n* Quick start your project with the [template repository](https://github.com/near/cargo-near-new-project-template) generated by `cargo near new` command\n* The associated [template repository](https://github.com/near/cargo-near-new-project-template)'s README contains a `Code \u003e Codespaces \u003e Create codespace on main` screenshot.\n* Clicking the button will result in using [Github Codespaces devcontainer](https://docs.github.com/en/codespaces). The containers allow you to start building without the need to install any dependencies on your machine and provide the actual version.\n\n## Installation\n\n\u003cdetails\u003e\n  \u003csummary\u003eInstall prebuilt binaries via shell script (Linux, macOS)\u003c/summary\u003e\n\n```sh\ncurl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.sh | sh\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eInstall prebuilt binaries via powershell script (Windows)\u003c/summary\u003e\n\n```sh\nirm https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.ps1 | iex\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eInstall prebuilt binaries into your Node.js application\u003c/summary\u003e\n\n```sh\nnpm install cargo-near\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eCompile and install from source code (Cargo)\u003c/summary\u003e\n\n```sh\ncargo install --locked cargo-near\n```\n\nor, install the most recent version from git repository:\n\n```sh\n$ git clone https://github.com/near/cargo-near\n$ cargo install --locked --path cargo-near\n```\n\u003c/details\u003e\n\n## Usage\n\nSee `cargo near --help` for a complete list of available commands or run `cargo near` to dive into interactive mode. Help is also available for each individual command with a `--help` flag, e.g. `cargo near build --help`.\n\n```console\ncargo near\n```\n\nStarts interactive mode that will allow to explore all the available commands.\n\n---\nUse `--teach-me` flag if you want to know \"how it works\".\n\n```console\ncargo near --teach-me\n```\n\nStarts an interactive mode with an explanation of the execution of the selected command.\n\n---\nAdditionally depends on [Git](https://git-scm.com/) binary being installed, besides [cargo](https://github.com/rust-lang/cargo).\n\n```console\ncargo near new\n```\n\nInitializes a new project skeleton to create a contract from a template.\n\n[Example](https://github.com/near/cargo-near/blob/main/docs/workflows.md) of github [workflows](https://github.com/near/cargo-near/blob/main/cargo-near/src/commands/new/new-project-template/.github/workflows) configuration, created by `cargo near new`.\n\n---\n\n```console\ncargo near build\n```\n\nBuilds a NEAR smart contract along with its [ABI](https://github.com/near/abi) (while in the directory containing contract's Cargo.toml).\n\nRunning the above command opens a menu with following variants: \n\n### `non-reproducible-wasm`\n\n**Recommended variant for use during local development.**\n\nThis is a regular build, which behaves much like and is a thin wrapper around a regular `cargo build --target wasm32-unknown-unknown --release`.\n\nAdditional flags for build configuration can be looked up if needed by:\n\n```bash\ncargo near build non-reproducible-wasm -h      # brief summary\ncargo near build non-reproducible-wasm --help  # detailed description of command \n```\n\n### `reproducible-wasm`\n\n**Recommended variant for the production releases.**\n\nThis variant runs a reproducible build in a [Docker](https://docs.docker.com/) container, which:\n\n1. runs against source code version, committed to git, ignoring any uncommitted changes\n2. requires that `Cargo.lock` of project is created (e.g. via `cargo update`) and added to git. \n    - this enables `--locked` build by downstream `cargo` command. \n3. will use configuration in [`[package.metadata.near.reproducible_build]`](https://github.com/near/cargo-near/blob/main/cargo-near/src/commands/new/new-project-template/Cargo.template.toml#L14-L29) \n   section of contract's `Cargo.toml` and [`package.repository`](https://github.com/near/cargo-near/blob/main/cargo-near/src/commands/new/new-project-template/Cargo.template.toml#L9) field\n    - default values for this section can also be found in `Cargo.toml` of \n      template project, generated by `cargo near new`\n\n**What's a reproducible build in context of NEAR?**\nWhy is it needed? Explanation of these points and a step-by-step tutorial is present at [SourceScan/verification-guide](https://github.com/SourceScan/verification-guide).\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdditional (optional) details on possible \u003ccode\u003e[package.metadata.near.reproducible_build]\u003c/code\u003e configuration\u003c/summary\u003e\u003cp\u003e\n  \n1. available images can be found by this link https://hub.docker.com/r/sourcescan/cargo-near/tags \n    - [`image`](https://github.com/near/cargo-near/blob/main/cargo-near/src/commands/new/new-project-template/Cargo.template.toml#L18) and [`image_digest`](https://github.com/near/cargo-near/blob/main/cargo-near/src/commands/new/new-project-template/Cargo.template.toml#L20) are straightforward to configure:\n  ![image_and_digest_pinpoint](https://github.com/near/cargo-near/blob/main/docs/image_and_digest_pinpoint.png)\n2. flags of build command, run inside of docker container, can be configured, if needed, by changing [`container_build_command`](https://github.com/near/cargo-near/blob/main/cargo-near/src/commands/new/new-project-template/Cargo.template.toml#L29) field\n      - base `container_build_command` for images starting with **sourcescan/cargo-near:0.13.0-rust-1.83.0** and after it  is `[\"cargo\", \"near\", \"build\", \"non-reproducible-wasm\", \"--locked\"]`, where the `--locked` flag is required\n      - base `container_build_command` for images prior to **sourcescan/cargo-near:0.13.0-rust-1.83.0** is `[\"cargo\", \"near\", \"build\"]` \n      - additional flags, if needed, can be looked up on\n          - `cargo near build non-reproducible-wasm --help` for newer/latest images \n          - `cargo near build --help` for older ones \n          - running `docker run -it sourcescan/cargo-near:0.11.0-rust-1.82.0` (or another specific image) and checking the `--help` message of exact `cargo-near` in container may be helpful when in doubt    \n3. `cargo near` allows parameterizing build with values of environment variables, present at the time of the build and not present in a contract's source code,\n   by specifying their names in [`passed_env`](https://github.com/near/cargo-near/blob/main/cargo-near/src/commands/new/new-project-template/Cargo.template.toml#L24) array\n    - supported by **sourcescan/cargo-near:0.10.1-rust-1.82.0** image or later images\n    - SourceScan/Nearblocks does not support verifying such contracts with additional parameters present in their metadata yet \n\n\u003c/p\u003e\u003c/details\u003e\n\nAdditional flags for build configuration can be looked up if needed by:\n\n```bash\ncargo near build reproducible-wasm -h      # replace `-h` with `--help` for more details\n```\n\n#### Custom `reproducible-wasm` build using `--variant \u003cname\u003e` flag\n\nBeyond your `[package.metadata.near.reproducible_build]` configuration, you can\ndefine **named variants of build** in your `Cargo.toml` under:\n\n```yaml\n[package.metadata.near.reproducible_build.variant.\u003cname\u003e]\n```\n\nIt supports all the same fields as `[package.metadata.near.reproducible_build]`:\n`image`, `image_digest`, `passed_env`, and `container_build_command`.\n\n**Note that every field is optional for variant build and will override\ncorresponding field in `reproducible_build`!**\n\nFor example, if you declare:\n\n```yaml\n[package.metadata.near.reproducible_build.variant.testnet-features]\ncontainer_build_command = [\n    \"cargo\",\n    \"near\",\n    \"build\",\n    \"non-reproducible-wasm\",\n    \"--locked\",\n    \"--features\",\n    \"testnet\"\n]\n```\n\nin `Cargo.toml`, and then:\n\n```bash\ncargo near build reproducible-wasm --variant testnet-features\n```\n\nwill use `testnet-features` version of `container_build_command`,\ninstead of one defined in `[package.metadata.near.reproducible_build]`.\n\n---\n\n```console\ncargo near abi\n```\n\nGenerates NEAR smart contract's [ABI](https://github.com/near/abi) (while in the directory containing contract's Cargo.toml).\n\nOnce contract is deployed, this will allow you to call a view function `__contract_abi` to retrieve a [ZST](https://facebook.github.io/zstd/)-compressed ABI.\n\n---\n\n```console\ncargo near create-dev-account\n```\n\nGuides you through creation of a new NEAR account on [testnet](https://explorer.testnet.near.org).\n\n---\n\n```console\ncargo near deploy\n```\n\nBuilds the smart contract (equivalent to `cargo near build`) and guides you to deploy it to the blockchain.\n\nSimilar to `build`, running the above command opens a menu with following variants: \n\n### `build-non-reproducible-wasm`\n\nThis forwards to [non-reproducible-wasm](#non-reproducible-wasm) variant of `build` command.\n\n### `build-reproducible-wasm`\n\nThis forwards to [reproducible-wasm](#reproducible-wasm) variant of `build` command.\n\n`deploy` command from Docker build requires that contract's source code:\n\n1. doesn't have any modified tracked files, any staged changes or any untracked content.  \n2. has been pushed to remote repository, identified by \n   [`package.repository`](https://github.com/near/cargo-near/blob/main/cargo-near/src/commands/new/new-project-template/Cargo.template.toml#L9).\n\n## Factories\n\nSee [`cargo_near_build::extended`](https://docs.rs/cargo-near-build/latest/cargo_near_build/extended/index.html) module documentation on \nhow to write `build.rs` for subcontracts. \n\n## Special `cargo` environment variables\n\nBoth of the following are mentioned on https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags\n\n### `RUSTFLAGS`  \n\nrunning e.g.\n\n```bash\nRUSTFLAGS=\"your_custom_value\" cargo near build non-reproducible-wasm\n```\nwon't result in `\"your_custom_value\"` affecting the build.\n\n`RUSTFLAGS=\"-Awarnings\"` is always used for abi build stage, and `RUSTFLAGS=\"-C link-arg=-s\"` for wasm build stage.\n\nLogic for concatenating default values of this variable with values from env was removed in `cargo-near-0.13.3`/`cargo-near-build-0.4.3`, as it was seen as\nan unnecessary complication.\n\nThere's still a way to override this parameter for wasm build stage, e.g.:\n\n```lang\ncargo near build non-reproducible-wasm --env 'RUSTFLAGS=--verbose'\nRUST_LOG=info cargo near build non-reproducible-wasm --env 'RUSTFLAGS=--verbose -C link-arg=-s'\n```\n\n### `CARGO_ENCODED_RUSTFLAGS`\n\nThis variable is always unset during build, so\n\n```bash\nCARGO_ENCODED_RUSTFLAGS=\"your_custom_value\" cargo near build non-reproducible-wasm\n```\nwon't result in `\"your_custom_value\"` affecting the build.\n\nThis is so to avoid weird issues like [#287](https://github.com/near/cargo-near/issues/287) when composing multiple builds via build scripts.\n\n\n\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as below, without any additional terms or conditions.\n\n## License\n\nLicensed under either of\n\n* Apache License, Version 2.0\n   ([LICENSE-APACHE](https://github.com/near/cargo-near/blob/main/LICENSE-APACHE) or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n* MIT license\n   ([LICENSE-MIT](https://github.com/near/cargo-near/blob/main/LICENSE-MIT) or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnear%2Fcargo-near","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnear%2Fcargo-near","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnear%2Fcargo-near/lists"}