We just updated the Tplus Sandbox images to the most recent Babylon protocol, and in this Guide, we will look at how to create a custom sandbox and deploy a smartpy contract with Tplus.

Prerequisites

Tplus will work on any Linux distribution, in this guide, we will use Ubuntu 18.04, before we install Tplus we have to make sure docker is installed with:

If docker is not installed on your system, see the instructions here: https://docs.docker.com/install/linux/docker-ce/ubuntu/

Installing Tplus

Since Docker is the only dependency that is needed, let's go ahead and install Tplus:

After we set up the tplus-server binary we need to

create a configuration file

create a new user

start tplus

At this point, the Web User-interface is running on your local machine and you are ready to create new sandboxes and nodes.

Behind the scenes

The Web interface hides a lot of what is actually happening so that developers can focus on their project and nothing else, but for the curious, here is a little explanation about how Tplus works:

The tplus-server binary is a golang application that talks directly to docker via Unix sockets, so there are no complicated bash scripts or docker-compose files to manually run. It can manage any number of Tezos nodes, sandboxed or public ones, every node is put into its own software-defined network, as well as other containers for plugins and so on, this way, each of those “environments” function completely independent of each other, and a bug or security issue in your sandbox environment can't reach anything in your Mainnet-Environment for example.

Our first Project

Now we will use the Web Interface to create our first Project, to do that we have to:

Create a Sandbox Environment

Wait for the tezos-node logs to show up

Install the Conseil plugin ( Conseil is used for an integrated blockchain explorer)

Create a new Project in the “IDE” tab

If you do this for the first time, it might take just a few minutes, as Tplus will fetch the docker images on demand, however, once those images are downloaded, future environment setups will be much faster.

Our first Contract

With the VsCode IDE ready, it is time to create our first contract, can you figure out what it does?

import smartpy as sp class CounterContract(sp.Contract):

def __init__(self, counter):

self.init(counter = counter) @sp.entryPoint

def myEntryPoint(self, increment):

self.data.counter += increment contract = CounterContract(0) import smartpybasic as spb spb.compileContract(contract,

targetBaseFilename = “./”)

print(“Contract compiled”)

After saving this code snippet to a file demo.py and compiling it with

$ smartpy demo.py

We end up with the compiled Michelson code in ./Code.tz , we can use this file to deploy the contract to our sandbox

$ tezos-client originate contract demoPy for bootstrap1 transferring 100 from bootstrap1 running ./Code.tz — init ‘1’ — burn-cap 0.4 & $ tezos-client bake for bootstrap3

Of course, this would be boring if we did not test our contract…

$ tezos-client transfer 0 from bootstrap2 to demoPy --arg '1'

$ tezos-client bake for bootstrap1

To inspect the changes we just applied to our sandbox, we can check either the tezblock explorer or better call dev, and find the origination operation, the call we made to the contract, and the corresponding change of the contract storage.

This is ( unfortunately ) the end of our little “Hello Tezos” example, I hope you now have a better idea of what Tplus can do, and are eager to try more, the following links might help with that!

tplus.dev

Tezos Developer Portal

SmartPy Documentation

Ligolang Documentation

If you have any Questions or Problems feel free to ask in the TulipTools Telegram Group

or join a lot of other Tezos Developers on our favorite chat:

https://riot.tzchat.org/