Release notes and unreleased changes can be found in the CHANGELOG
Install prebuilt binaries via shell script (Linux, macOS)
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.sh | shInstall prebuilt binaries via powershell script (Windows)
irm https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.ps1 | iexInstall prebuilt binaries into your Node.js application
npm install cargo-nearCompile and install from source code (Cargo)
cargo install --locked cargo-nearor, install the most recent version from git repository:
$ git clone https://github.com/near/cargo-near
$ cargo install --locked --path cargo-nearSee 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.
cargo nearStarts interactive mode that will allow to explore all the available commands.
Additionally depends on Git binary being installed, besides cargo.
cargo near newInitializes a new project skeleton to create a contract from a template.
cargo near buildBuilds a NEAR smart contract along with its ABI (while in the directory containing contract's Cargo.toml).
By default, this runs a reproducible build in a Docker container, which:
- runs against source code version, committed to git, ignoring any uncommitted changes
- requires that
Cargo.lockof project is created (e.g. viacargo update) and added to git.- this enables
--lockedbuild by downstreamcargocommand.
- this enables
- will use configuration in
[package.metadata.near.reproducible_build]section of contract'sCargo.tomlandpackage.repositoryfield- default values for this section can also be found in
Cargo.tomlof template project, generated bycargo near new
- default values for this section can also be found in
Important flags:
-
--no-docker- flag can be used to perform a regular build with rust toolchain installed onto host, running the
cargo-nearcli. - NO-Docker builds run against actual state of code in filesystem and not against a version, committed to source control.
- flag can be used to perform a regular build with rust toolchain installed onto host, running the
-
--no-locked- flag is allowed in NO-Docker builds, e.g. to generate a
Cargo.lockand simultaneously build the contract. - flag is allowed in Docker builds, but
- such builds are not reproducible due to potential update of dependencies and compiled
wasmmismatch as the result.
- such builds are not reproducible due to potential update of dependencies and compiled
- flag is allowed in NO-Docker builds, e.g. to generate a
cargo near abiGenerates NEAR smart contract's ABI (while in the directory containing contract's Cargo.toml).
Once contract is deployed, this will allow you to call a view function __contract_abi to retrieve a ZST-compressed ABI.
cargo near create-dev-accountGuides you through creation of a new NEAR account on testnet.
cargo near deployBuilds the smart contract (equivalent to cargo near build) and guides you to deploy it to the blockchain.
By default, this runs a reproducible build in a Docker container.
deploy command from Docker build requires that contract's source code:
- doesn't have any modified tracked files, any staged changes or any untracked content.
- has been pushed to remote repository, identified by
package.repository.
Important flags:
-
--no-docker- flag can be used to perform a regular NO-Docker build and deploy.
- Similar to
buildcommand, in this case none of the git-related concerns and restrictions apply.
- Similar to
- flag can be used to perform a regular NO-Docker build and deploy.
-
--no-locked- flag is declined for deploy, due to its effects on
buildresult
- flag is declined for deploy, due to its effects on
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as below, without any additional terms or conditions.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.