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).
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.
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
Coming soon
-
Install Rust with correct build target
-
Clone nearcore
git clone https://github.com/near/nearcore
-
cd
into yournearcore
folder and runmake 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/
-
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
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
NEAR Sandbox includes custom features to make tweaking local and test environments easier.
sandbox_patch_state
RPC call, used bypatchState
in runner-js, useful for making arbitrary state mutations on any contract or account