Create Publication

We are looking for publications that demonstrate building dApps or smart contracts!
See the full list of Gitcoin bounties that are eligible for rewards.

Article Thumbnail

Introducing Sandbox 2.0

The first version of Sandbox was created as an internal Algorand hackathon project. Over the past year it’s proven to be extremely useful to have easy access to a disposable Algorand node environment. With Sandbox 2.0 we’ve taken all of our favorite features and added in some new ones to make the Sandbox even better.

Why use Sandbox?

First and foremost Sandbox is a tool for developers. It streamlines the process of setting up an Algorand node in a containerized environment. If you’re developing an application and need a test environment, look no further.

What’s new?

  • Preloaded accounts are ready to use immediately after the environment has started. This is done by creating a private network environment inside the Sandbox.
  • Indexer is now available with most Sandbox configurations, alongside the algod and kmd endpoints. The postgres backing database is also available for adventurous developers who who want to explore how Indexer stores its data.
  • Fast-catchup is used for Sandbox configurations that connect to real networks. In addition to mainnet, testnet and betanet, we now also have a configuration for devnet.
  • Run any version. Any release channel, any branch, any repository. In addition to our standard release channels you’re now able to specifying a git URL, branch and optional commit hash. The Sandbox will build your code from scratch and start the environment.
  • Faster than ever. By defaulting to a private network there is no catchup required.

Dependencies

  • Docker-Compose must be installed and docker should be running.
  • Sandbox. The entire repository should be copied into a new directory.

How to use Sandbox

Things haven’t changed much when it comes to how you use the Sandbox. We wanted to keep things streamlined and easy to use, that was one of our favorite things from the first version. To that end, the base commands are essentially the same as they were before.

To bring up the default private network use ./sandbox up:
EditorImages/2020/11/25 20:58/sandbox_2.0_up.png

As you can see there are 3 accounts ready to use, and an example command is displayed which will create a transaction to transfer funds between two of them.

In addition there is an example to show you how to query for the transaction with Indexer.

To get a better idea about how to use some of the different sandbox endpoints, run ./sandbox test:
EditorImages/2020/11/25 20:55/sandbox_2.0_test.png

Built in configurations

The following up configurations come with Sandbox, and can be used with ./sandbox up <config>.

Private network configurations:

  • release - stable dev build of algod and master branch of Indexer.
  • nightly - nightly dev build of algod and the dev branch of Indexer.
  • beta - beta build of algod and dev branch of Indexer.
  • dev - dev branch of algod and indexer, building algod takes a while so this will be slower than the other private network configurations.

There is also a configuration for each of the long-running networks:

  • mainnet
  • testnet
  • betanet
  • devnet

Advanced Configuration

The configuration profiles are stored in files named config.<name>, where <name> is passed to the up command. For examples you can see the built in configurations like config.nightly and config.betanet.

Creating your own is easy, copy one of hte existing configurations and modify the settings. For example, here is a configuration that will build custom versions of algod and Indexer:

# If defined uses an algod release channel
export ALGOD_CHANNEL=""

# Build algod from source
export ALGOD_URL="https://github.com/winder/go-algorand"
export ALGOD_BRANCH="will/test"
export ALGOD_SHA="ffb3b20dfe1b8aa803229d5622fcf1a880616969"

# If defined attempts to connect to a real network
export NETWORK=""
export NETWORK_BOOTSTRAP_URL=""
export NETWORK_GENESIS_FILE=""

# Build Indexer from source
export INDEXER_URL="https://github.com/algorand/indexer"
export INDEXER_BRANCH="will/test"
export INDEXER_SHA=""

# If defined indexer is disabled
export INDEXER_DISABLED=""