Tezster Bundles: Boilerplates for Dapp Development on Tezos

Dibyo Majumder | Heisenberg
Tezsure
Published in
5 min readApr 21, 2020

Ethereum has Truffle Boxes, but on Tezos we have Tezster Bundles!

Compile SmartPy code on your local machine, deploy on a testnet or local sandbox using Tezster (Comparable to Ganache on Ethereum) and interact with your Dapps using front-end boilerplates.

What was Tezster again?

A complete toolbox to build, deploy and interact with smart contracts and decentralized applications on Tezos using a local sandbox or a remote testnet.

The Tezster-CLI comes in an npm package with a set of easy commands to kickstart the development or interaction with Tezos blockchain. It allows you to interact with local nodes as well as remote testnet nodes and deploy or call smart contracts. To get a complete understanding of the different components check out the documentation.

What is a Tezster Bundle?

A Tezster Bundle is an example Tezos application that pulls together complementary tools from the Tezos ecosystem and raps it in one easy-to-use bundle.

It includes local compiling of SmartPy contracts, a keystore manager and deployment features. You can compile your smart contract using SmartPyBasic and deploy it locally using the Tezster-CLI.

We made this bundle for new developers entering the Tezos ecosystem, so that time can be saved from searching for all the individual tools and find a way to make them sing together. This gives new developers all the time and focus to build awesome Tezos applications.

The First One: bundle-react

Our first Front-end ready Bundle comes with React!

Clone the repository here.

Setup & Run Steps

npm install will install all your dependencies.

npm run client-install will install all the client dependencies i.e in React.

Now you are ready to write your SmartPy Smart Contract

This is how a Smart Contract in SmartPy looks like :

import smartpy as spclass MyContract(sp.Contract):
def __init__(self, myParameter1, myParameter2):
self.init(myParameter1 = myParameter1,myParameter2 = myParameter2)

@sp.entry_point
def myEntryPoint(self, params):
sp.verify(self.data.myParameter1 <= 123)
self.data.myParameter1 += params
contract = MyContract(12, 13)

Note: You don’t need to explicitly add the initial storage somewhere. Just initialize the contract class like a normal python class.

This part should be kept intact as it helps to build your contract :

import smartpybasic as spb
spb.compileContract(contract,targetBaseFilename = "./contract_build/Contract")
print("Contract compiled in ./contract_build/ContractCode.tz")

Once done writing your Smart Contract inside ./contract you have to configure the config.json file.

Configuring config.json

Open the config.json file. Inside you have to mention demo.py inside the contract_name section.

Note: You have to be specific about the file name, otherwise it will throw an error. We have provided an initial config which compiles the ./contract/demo.py

"compile_config" : {
"contract_name": "demo.py"
}

Time to Compile!

npm run sync is a syncing command. Whenever the compile_config is changed in config.json this command must be executed from the terminal. This command helps the bundle to reconfigure the compilation parameters according to the changes you have made.

npm run compile will build the contracts locally inside the folder ./contract_build.

The contract_build folder will contain the following files :

  • ContractCode.tz: Michelson Code of your Smart Contract.
  • ContractCode.tz.json: Micheline Code of your Smart Contract.
  • ContractExpression.smlse: an internal expression between SmartPy and SmartML, kept for the record but not directly useful.
  • ContractStorage.tz: Micheline representation of the Storage.
  • ConractTypes.tz: It specifies the types of params used in the contract.

Configuring Deployment Parameters

Open the config.json file again and go to the deploy_config section.

First we have to mention the Tezos node. It can be on your local machine or any remote node.

Public available testnets:

Next, You can change the contractCode and ContractStorage with the ones you want to deploy.

Don’t forget to set the parameters amount, gas_limit, derivation_path, etc.

"deploy_config" : {
"node" : "https://testnet.tezster.tech",
"contract_code" : "ContractCode.tz",
"contract_storage" : "ContractStorage.tz",
"key" : "test_key1",
"amount" : 100,
"delegate_address" : "",
"fee" : 100000,
"derivation_path" : "",
"storage_limit" : 10000,
"gas_limit" : 100000
}

How To Interact With Your Smart Contract

We are using the Conseil node to interact with our smart contract. To use the Conseil node you need an API Key.

https://conseil-dev.cryptonomic-infra.tech:443/

Use https://nautilus.cloud to access the API KEY for the Conseil node. Use https://faucet.tzalpha.net/ to obtain keys for any testing. You can use http://smartpy.io/dev/faucetImporter.html to activate the keys obtained from the faucet.

Contract Specifications:

contract_code: should refer to the Michelson Contract code you want to deploy.

contract_storage: refers to the Michelson representation of the initial storage used for deployment.

This bundle is provided with 6 Keys in the Keystore

Both test_key1.js & test_key2.js are activated in the tezos alphanet. You can use them or import your own from the faucet. Activate and reveal using the ConseilJsUtils.

4 bootstrap accounts are provided which can be directly used with our Tezster Suite which provides a local development Blockchain with unique ease of interaction with the Tezos node!

To deploy your contracts in the local tezos blockchain you first need to Setup Tezster-CLI / Tezster-GUI.

Once done just change the deploy_config.node: “http://localhost:18731"

Note: By default, the tezos-node runs in 18731 for Tezster.

Remaining keys are the contract deployment params which includes :

  • amount you want to send to the contract (in micro Tez).
  • delegate_address to whom you want to delegate your contract balance (tz1 address).
  • fee to the baker (in micro Tez).
  • storage_limit for the contract (limits the storage used by the contract).
  • gas_limit to restrict the actions/operations to be carried out while deployment.

Yes, Now We Are Finally Deploying!

npm run deploy will deploy your contract with the params from our config.json file.

npm run dapp will spin-up the React front-end and you are ready to go!

This Bundle contains a simple create-react-app. Once you run the command the front-end dev server will start up and you will be redirected to your home page in your default browser.

The package comes with a React Ready front-end, ready-to-use. The ConseilJS library can be used to interact with the smart contract.

Want to learn more about Tezsure, Tezster and OrO? Stay in touch.

Website | Twitter | LinkedIn |

--

--

Dibyo Majumder | Heisenberg
Tezsure
Editor for

CEO & Founder Turf Gaming | 2x Entrepreneur | Built @instaraise | Strategy & Product Architect | Built on top of Ethereum, Tezos, Polygon