Skip to content

Easily run a local NEAR blockchain

License

GPL-3.0 and 2 other licenses found

Licenses found

GPL-3.0
LICENSE
Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

near/near-sandbox

This branch is 1 commit ahead of, 42 commits behind main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
release-plz
Sep 30, 2023
ccdb8ab · Sep 30, 2023
Sep 30, 2023
Sep 30, 2023
Sep 25, 2023
Oct 4, 2021
Sep 30, 2023
Sep 30, 2023
Sep 25, 2023
Aug 12, 2021
Aug 12, 2021
Dec 16, 2021
Jul 26, 2022

NEAR Sandbox

NEAR Sandbox lets you easily run a local NEAR blockchain.

NEAR Sandbox is a custom build of the NEAR blockchain optimized for local development and testing. If you're familiar with Ganache for Ethereum, this is similar.

This repository contains code to quickly install pre-built binaries of NEAR Sandbox for multiple programming languages (currently just NodeJS; Rust coming soon) and operating systems (currently just Intel-based Macs and Debian/Ubuntu-flavored Linux distros using Intel processors).

Using NEAR Sandbox

If you just want to run tests against a NEAR Sandbox instance, check out near-workspaces for your favorite language:

Tip: near-runner includes near-sandbox as a dependency, so you will not need to install or run near-sandbox on its own.

If you want to run NEAR Sandbox on its own, continue reading.

Install

With npm

npm i -g near-sandbox

Note: If you have trouble downloading binary from IPFS gateway, you can upload a pre-built near-sandbox tar file to any file storage service and use SANDBOX_ARTIFACT_URL environment variable to specify it's base URL. e.g. > SANDBOX_ARTIFACT_URL=https://s3.aws.com/my-binary npm i near-sandbox

With Rust

Coming soon

From Source

  • Install Rust with correct build target

  • Clone nearcore

    git clone https://github.com/near/nearcore
    
  • cd into your nearcore folder and run make sandbox

    cd nearcore
    make sandbox
    
  • For ease-of-use, you can copy (or symlink) the binary to somewhere in your PATH. For example, if you have a ~/bin folder:

    cp target/debug/near-sandbox ~/bin/
    

Use

  • Initialize the Sandbox node

    near-sandbox --home /tmp/near-sandbox init
    
  • Run it

    near-sandbox --home /tmp/near-sandbox run
    

To find out other things you can do:

near-sandbox --help

Stop

Once you're finished using the sandbox node you can stop it by using CtrlC. To clean up the data it generates:

rm -rf /tmp/near-sandbox

What's special about NEAR Sandbox

NEAR Sandbox includes custom features to make tweaking local and test environments easier.

  • sandbox_patch_state RPC call, used by patchState in runner-js, useful for making arbitrary state mutations on any contract or account