#near #build-script #cargo-near #crate-cli

cargo-near-build

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

16 releases (5 breaking)

new 0.6.0 May 3, 2025
0.4.6 Apr 8, 2025
0.4.5 Mar 24, 2025
0.4.2 Dec 19, 2024
0.3.2 Nov 19, 2024

#29 in #near

Download history 1245/week @ 2025-01-12 1348/week @ 2025-01-19 1509/week @ 2025-01-26 1622/week @ 2025-02-02 2786/week @ 2025-02-09 1325/week @ 2025-02-16 1521/week @ 2025-02-23 1932/week @ 2025-03-02 1611/week @ 2025-03-09 2669/week @ 2025-03-16 2120/week @ 2025-03-23 1702/week @ 2025-03-30 2829/week @ 2025-04-06 1399/week @ 2025-04-13 2018/week @ 2025-04-20 1039/week @ 2025-04-27

7,413 downloads per month
Used in 6 crates (2 directly)

MIT/Apache

150KB
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–17MB
~263K SLoC