Release Notes
Release notes can be found in the CHANGELOG.
Requirements
- Rust v1.85.0 or newer.
- MacOS (ARM64) or Linux (x86) for sandbox execution.
What is NEAR Sandbox?
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 serves a similar purpose for NEAR.
This library provides a Rust API to easily start and configure your local NEAR Sandbox instance. The sandbox binary is automatically downloaded and managed for you.
There are near-sandbox packages available in other programming languages, see here.
Installation
Add near-sandbox to your [dependencies] or [dev-dependencies]:
Simple Testing Example
use Sandbox;
async
Examples
More examples can be found in the examples/ directory.
Features
- Easy sandbox startup: Start a local NEAR node with default or custom configuration.
- Version selection: Choose a specific NEAR Sandbox version.
- Custom configuration: Configure the
config.jsonandgenesis.jsonfor yournear-sandboxinstance. - Automatic binary management: The required sandbox binary is downloaded and managed automatically.
- RPC access: Interact with your sandbox node via its RPC endpoint.
- Environment variable configuration: Control binary source, logging, and timeouts via environment variables.
Starting a Sandbox
use ;
async
Accessing RPC
use Sandbox;
async
Configuring RPC
use ;
use json;
async
Automatic near-sandbox Binary Management
- When you start a sandbox, the appropriate binary for your platform is automatically downloaded if it is not already present.
- The sandbox process runs in the background.
- When the
Sandboxstruct is dropped, the process is automatically killed.
Environment Variables
Customize sandbox behavior with these environment variables:
SANDBOX_ARTIFACT_URL: Override the download link forneard. Useful if you have trouble downloading from the default IPFS gateway.NEAR_RPC_TIMEOUT_SECS: Set the timeout (in seconds) for waiting for the sandbox to start (default: 10).NEAR_SANDBOX_BIN_PATH: Use your own pre-builtneard-sandboxbinary instead of the default. Be careful not to use NodeJs package!NEAR_ENABLE_SANDBOX_LOG: Set to1to enable sandbox logging ofnear-sandbox(helpful for debugging).NEAR_SANDBOX_LOG: Specify custom log levels for the sandbox (forwarded to theRUST_LOGenvironment variable).NEAR_SANDBOX_LOG_STYLE: Specify custom log style for the sandbox (forwarded to theRUST_LOG_STYLEenvironment variable).
API Reference
API documentation is available at docs.rs/near-sandbox.