Skip to content

Commit

Permalink
Using sandboxes including new Tezbox sandbox (#380)
Browse files Browse the repository at this point in the history
* Using sandboxes including new Tezbox sandbox

* Got to run your own indexer

* Tezbox follows Octez versions
  • Loading branch information
timothymcmackin authored Apr 17, 2024
1 parent 02c06c7 commit 98beac8
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 10 deletions.
78 changes: 69 additions & 9 deletions docs/developing/sandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,82 @@
title: Using a local sandbox
authors: 'Mathias Hiron, Nomadic Labs, Tim McMackin, TriliTech'
last_update:
date: 18 October 2023
date: 16 April 2024
---

Local sandboxes allow you to test your work without sending any transactions to Tezos Mainnet or testnets.
They run a simulated version of the Tezos protocol locally so you can test contracts, dApps, or other projects while interacting with actual nodes, but without using a public test network or creating your own private network.

The **sandboxed mode** of `octez-client` makes it possible to test your contracts or other projects while interacting with actual nodes, but without using a public test network or creating your own private network. In sandboxed mode, `octez-client` can create one or more local nodes for this.
Sandboxes can be convenient if you want to run all your tests locally but still need a realistic Tezos environment, such as if you need to interact with nodes and the consensus mechanism.
Testing locally can also keep your work confidential until you decide to put it into production.

This is convenient if you want to run all your tests locally but in a mode where blocks are actually created through the consensus mechanism. In particular, if your contracts or tests must stay confidential until you decide to put them into production.
However, sandboxes lack some features that [testnets](./testnets) have, such as indexers.
If you want an indexer or your testnet, you must run it yourself.

In this mode, you can't use public services such as public block explorers or indexers. You may however install your own.
Here are some options for running local Tezos sandboxes:

One of the fastest ways to run a sandbox network is to use Docker. The [Flextesa](https://tezos.gitlab.io/flextesa/) Docker image allows you to set up a sandbox quickly with the protocol of your choice and pre-funded accounts.
## Octez sandboxed mode

Find out more in the [documentation of the sandboxed mode](https://tezos.gitlab.io/user/sandbox.html).
The sandboxed mode of the Octez client runs a local version of the Tezos network.
You can configure the number features such as the number of nodes.

## Further reading
For more information, see [Sandboxed mode](https://tezos.gitlab.io/user/sandbox.html) in the Octez documentation.

- [Mockup mode](https://tezos.gitlab.io/user/mockup.html)
- [Sandboxed mode](https://tezos.gitlab.io/user/sandbox.html)
## Flextesa

The [Flextesa](https://tezos.gitlab.io/flextesa/) is a simulated Tezos environment that runs in a container.

The Flextesa image has different scripts that start different versions of the Tezos protocol.
For example, to start a Flextesa sandbox with the Oxford protocol, run this command:

```bash
image=oxheadalpha/flextesa:latest
script=oxfordbox
docker run --rm --name "$script" --detach -p 20000:20000 \
-e block_time=3 \
"$image" "$script" start
```

Then you can see the accounts that are available by running this command:

```bash
docker exec $script $script info
```

The Flextesa image comes with the Octez client pre-configured, so you can use it directly from the image.
These commands create an alias for the installation of the Octez client in the image and uses it from the host system:

```bash
alias tcli='docker exec my-sandbox octez-client'
tcli get balance for alice
```

Now you can use the Octez client to deploy contracts and send transactions to the sandbox.

Flextesa allows you to control baking manually, so blocks are only backed when you trigger them.

For more information, see the [Flextesa documentation](https://tezos.gitlab.io/flextesa/).

## Tezbox

[Tezbox](https://github.com/tez-capital/tezbox) is also a simulated Tezos environment that runs in a container.

Tezbox provides different images that mirror versions of the Octez suite.
For example, to run Tezbox with Octez version 19.1 and the Oxford protocol, run this command:

```bash
docker run -d -p 0.0.0.0:8732:8732 --name oxfordbox ghcr.io/tez-capital/tezbox:tezos-v19.1
```

The container runs in the background and provides an RPC node at http://localhost:8732.

Then you can use the sandbox through that RPC node.
For example, you can configure the Octez client to use the sandbox by running this command:

```bash
octez-client -E http://localhost:8732 config update
```

Then you can use your local installation of the Octez client to interact with the sandbox, such as deploying contracts and sending transactions.

Tezbox provides sample accounts in the `/tezbox/context/accounts.json` file.
2 changes: 1 addition & 1 deletion sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const sidebars = {
'developing/wallet-setup',
'developing/testing',
'developing/testnets',
// 'developing/sandbox', // TODO
'developing/sandbox',
{
type: 'category',
label: 'The Octez client',
Expand Down

0 comments on commit 98beac8

Please sign in to comment.