Ligo Development: Preparing Environment

by Anastasiia Kondaurova

Nowadays, when Tezos ecosystem is growing rapidly there are a number of development tools with strong support and further upgrade that are intended to make developer’s life easier. Choosing the right development kit is essential for success. In this article, we consider the most popular solutions such as:

  • Ligo IDE
  • Truffle + Ganache + pascaligo-vscode Plugin
  • Baking Bad IDE

Ligo IDE

Ligo IDE provides the way to dive into smart contract development seamlessly without installing any tools or plugins locally. The IDE offers you to write, deploy and test your contracts manually in your Browser. It is one of the most convenient environments for beginners.

If you open the IDE you will see something like this:

Ligo IDE

The mock contract is pretty useful to start playing around with the IDE and explore its features. However, if it is one of the standard’s implementations (e.g, FA2) it would be more efficient.

Perks

  • Code highlighting.
  • Ability to compile and deploy smart contracts, estimate the transactions.
  • Ability to generate deployment script.
  • Support of all Ligo dialects.

Flaws

  • Changes made in IDE aren’t stored. Reloading the page reset the code to the default counter contract.
  • No code analysis.
  • No web wallet integration. Deployment can only be done with their key or via Tezbridge.
  • Contracts can’t be imported.
  • No automated testing tools.

Truffle + Ganache + pascaligo-vscode Plugin

Those who are familiar with Ethereum development are likely to hear about Truffle Suit. The experience is almost the same but with some limitations.

Disclaimer: if you are good at Solidity development you may be interested in the interactive Solidity to Ligo course.

Ganache-cli Setup

Ganache is a sandbox blockchain for rapid development. Install the Tezos-specific version:

npm install -g ganache-cli@tezos

The Ganache-cli utilizes the flextesa docker image so the Docker should be installed beforehand. To launch the blockchain run:

ganache-cli --flavor tezos --seed alice

If the node is successfully started you will see:

Ganach-cli started

Ethereum node is run by default so the —flavor is required to run the Tezos one.  --seed is helpful to generate the same initial accounts every launch. Delphinet protocol is chosen by default if you are willing to work with the newest Edonet the --hardfork option can be set:

ganache-cli --flavor tezos --seed alice --hardfork edo

However, using Edonet node with the Truffle framework is discouraged as it’s not supported yet.

Truffle Setup

Truffle is a featured tool and environment for compiling, deploying and testing your contracts.

Truffle uses the latest dockerized Ligo version so the documentation for Ligo:next should be considered as the most relevant.

Install the tool globally:

npm install -g truffle@tezos

Then to set up the environment for the specific project run:

mkdir tezos-env && cd tezos-envtruffle unbox tezos-example-box

Using truffle init isn’t recommended because the default unboxed project relays on the old ganache version and is broken now.

Warm-up

The project contains the code for a couple of contracts. You can easily compile, deploy, and test them.

To compile the contracts run:

truffle compile

The successful result looks like this:

Contracts compiled

It will use dockerized ligo compiler to compile your contracts and store artifacts to ./build/contracts subdirectory.

If the local network is still up the migrations scripts that are stored in the ./migrations directory can be executed to deploy the contracts to the network. Run:

truffle migrate

The output of migrations is quite big and displays all the information about origination operations.

./test folder contains some automated tests and if you are interested in auto checks run:

truffle test

Pascaligo-vscode Plugin

And the cherry on top is a vscode plugin. It serves the only purpose which is code highlight for Ligo contracts. Without it smart contract development is unbearable.

Pascaligo-vscode in the action

Perks

  • Create as many environments as you need.
  • Ability to compile and deploy smart contracts, evaluate the transactions.
  • Migrations and automated tests can be implemented and run both in the sandbox and real chains.
  • The sandbox node doesn’t require any extra configurations. The protocol is automatically activated.
  • Contracts are stored locally and the code won’t be lost.

Flaws

  • No support for Edonet protocol in Truffle.
  • Code analysis isn’t supported in vscode plugin.

Baking Bad IDE

Bbbox is another IDE. It is designed for Michelson and SmartPy smart contract development so to compile your Ligo contracts the other tools should be used. But the key feature of the IDE is the ability to run the explorer for your sandbox blockchain, it allows you to explore all the network, contract code, and interactions, and many other things.

To get the code and start the node and explorer run:

git clone <https://github.com/baking-bad/bbbox.git> && cd bbboxmake 

It will load a dozen of docker images and run the appropriate containers. It takes some time. Be patient. Then all the useful information related to the local blockchain can be explored:

Baking Bad IDE

There is not much information at the start but if you go back to the tezos-example-box project and run migrations there will be something interesting:

Exploring last transactions
Exploring contract calls

It is better to use bbbox along with Truffle as an alternative for ganache-cli or in the context of pure SmartPy or Michelson smart contract development.

Perks

  • Powerful UI to explore the blockchain events.
  • Ability to store chain snapshots.
  • Variety of configurations.

Flaws

  • No support for Ligo smart contracts.

Conclusion

To sum up, we have explored the most vivid tools for smart contract development on Ligo. They have their own pros and cons and we hope you have found something the fits your goals the most. In the next post, we will write the first contract and deploy it to the sandbox network.

Stay in touch!

Helpful resources and docs:

  1. https://www.trufflesuite.com/docs/tezos/truffle/quickstart — Truffle docs
  2. https://tezostaquito.io/ — Taquito docs (aka. web3 for Tezos)
  3. https://thanoswallet.com/ — Tezos web wallet
  4. https://ligolang.org/docs/intro/introduction — Ligo docs
  5. https://join.slack.com/t/tezos-dev/shared_invite/zt-in60mgbm-E1Os9pdhiODnNui85w1_jA — dev channel
  6. https://gitlab.com/tzip/tzip — proposals, standards (similar to EIPs)
  7. https://tezosacademy.io/, https://tezos-monsters.com/ — games for Ligo learning
  8. https://learn.tqtezos.com/ — Tezos high-level docs
  9. https://tezos.gitlab.io/whitedoc/michelson.html — Michelson docs
  10. https://better-call.dev/ — advanced explorer

You may also like

Leave a Comment