npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cargo-near

v0.11.0

Published

Cargo extension for building Rust smart contracts on NEAR

Downloads

285

Readme

Release notes

Release notes and unreleased changes can be found in the CHANGELOG

Installation

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.sh | sh
irm https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.ps1 | iex
npm install cargo-near
cargo install --locked cargo-near

or, install the most recent version from git repository:

$ git clone https://github.com/near/cargo-near
$ cargo install --locked --path cargo-near

Usage

See 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 near

Starts interactive mode that will allow to explore all the available commands.


Additionally depends on Git binary being installed, besides cargo.

cargo near new

Initializes a new project skeleton to create a contract from a template.

Example of github workflows configuration, created by cargo near new.


cargo near build

Builds 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:

  1. runs against source code version, committed to git, ignoring any uncommitted changes
  2. requires that Cargo.lock of project is created (e.g. via cargo update) and added to git.
    • this enables --locked build by downstream cargo command.
  3. will use configuration in [package.metadata.near.reproducible_build] section of contract's Cargo.toml and package.repository field
    • default values for this section can also be found in Cargo.toml of template project, generated by cargo near new

Important flags:

  1. --no-docker

    • flag can be used to perform a regular build with rust toolchain installed onto host, running the cargo-near cli.
    • NO-Docker builds run against actual state of code in filesystem and not against a version, committed to source control.
  2. --no-locked

    • flag is allowed in NO-Docker builds, e.g. to generate a Cargo.lock and simultaneously build the contract.
    • flag is allowed in Docker builds, but
      • such builds are not reproducible due to potential update of dependencies and compiled wasm mismatch as the result.

cargo near abi

Generates 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-account

Guides you through creation of a new NEAR account on testnet.


cargo near deploy

Builds 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:

  1. doesn't have any modified tracked files, any staged changes or any untracked content.
  2. has been pushed to remote repository, identified by package.repository.

Important flags:

  1. --no-docker

    • flag can be used to perform a regular NO-Docker build and deploy.
      • Similar to build command, in this case none of the git-related concerns and restrictions apply.
  2. --no-locked

    • flag is declined for deploy, due to its effects on build result

Contribution

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.

License

Licensed under either of

at your option.