#cargo-subcommand #smart-contracts #cargo-near #docker #basis

cargo-near-build

Library for building Rust smart contracts on NEAR, basis of cargo-near crate/CLI

21 releases (8 breaking)

0.9.0 Sep 14, 2025
0.7.2 Jul 8, 2025
0.4.5 Mar 24, 2025
0.4.2 Dec 19, 2024
0.3.2 Nov 19, 2024

#25 in #basis

Download history 1857/week @ 2025-08-19 2702/week @ 2025-08-26 2270/week @ 2025-09-02 2302/week @ 2025-09-09 1668/week @ 2025-09-16 1547/week @ 2025-09-23 1249/week @ 2025-09-30 1287/week @ 2025-10-07 1572/week @ 2025-10-14 1320/week @ 2025-10-21 1575/week @ 2025-10-28 2371/week @ 2025-11-04 1888/week @ 2025-11-11 3268/week @ 2025-11-18 3899/week @ 2025-11-25 3166/week @ 2025-12-02

12,753 downloads per month
Used in 6 crates (2 directly)

MIT/Apache

165KB
3.5K SLoC

Crate features

  • build_external - Exports crate::build_with_cli function which builds contracts by running external cargo-near binary with std::process::Command
  • build_internal - The whole functionality, needed for build and ABI generation, mostly for internal use by cargo-near CLI implementation
  • docker - Adds docker module for functionality of building in docker with WASM reproducibility.
  • test_code - Adds exports needed for integration tests.

Default features

build_external

Re-exports

  1. camino is re-exported, because it is used in BuildOpts as type of some of fields
  2. near_abi is re-exported (under build_internal feature), because details of ABI generated depends on specific version of near-abi dependency
  3. [bon] is re-exported for the convenience of bon::vec helper macro

Sample usage:

Default:

let artifact = cargo_near_build::build_with_cli(Default::default()).expect("some error during build");

With some options set:

let build_opts = cargo_near_build::BuildOpts::builder().features("some_contract_feature_1").build();
let artifact = cargo_near_build::build_with_cli(build_opts).expect("some error during build");

Dependencies

~3–20MB
~274K SLoC