Ideal for beginners: visual programming of smart contracts using Visualtez
Who needs visual programming
In May, the visualtez visual programming service appeared on Tezos. The developer selects the necessary blocks with the mouse, unites them and sets arguments, and the service does everything else. We collected the simplest Calculator contract in Visual TEZ and immediately tested it. We share the sensations from visual programming of smart contracts on Tezos and talk about the features of this tool.
Firstly, it is suitable for creating simple scripts without studying the platform. For example, using the Automate application, you can program the smartphone to turn off WiFi if it is outside your home or office according to GPS coordinates. You do not need to know Java and functions for working with WiFi and GPS.
Secondly, visual programming allows narrow specialists to concentrate on solving a specific creative problem. Examples-Blueprints in Unreal Engine for working with graphic shaaders, Audiomulch for writing music, houdini for 3D animation.
Thirdly, programming using blocks and shooters is useful for learning beginners who are not yet used to operating with abstractions or confused in the syntax and semantics of the language.
In general, visual programming is suitable for people who know what to do, but have not yet fully mastered the programming language or do not have time to learn it. It is also useful for prototyping and experiments when it goes faster to collect several blocks with a mouse than to write twenty lines.
How to work with Visualtez
There are two main links on the main screen – to the editor (IDE) and documentation . Moreover, the documentation explains only work with blocks, compilation and testing of contracts in Visualtez. If you need to find out how the big_map differs from the Record and what is the storage – read our course on the development or documentation of Smartpy .
Visualtez retains the progress of the workshop and allows you to share permanent links to your contract. The content of the workshop will not disappear if you accidentally close the browser or restart the tab.
On the left side there is a menu with blocks:
- Main blocks (Main Blocks)-containers that are responsible for compilation of smart contracts, meanings and types;
- values (Data Values);
- data types (Types);
- Operations by type (Operations by Type) – get the length of the line, delete the key from MAP and others;
- Variables operations – ad, appropriation, access;
- Logical operations (logic);
- Cycles and iterations (looks);
- mathematical functions (arithmetics/math) like ABS and shift operators;
- Transfer and delegation of TEZ (Transfer), as well as a challenge of a third -party contract and deflect;
- access to onchain data (Block/TX Properties) – functions like Get Sender;
- cryptographic functions (Cryptography), for example, checking the signature;
- advanced expressions for packaging and unpacking data;
- lambda-calculations;
- on-chain Views;
- Functions for testing.
On the right side – tools for working with contracts: compilation and testing, FA1 templates.2 and FA2, generation of links to Vorkspace with your contract, import and export of contracts in format .XML and others.
Contracts are compiled in Michelson, Json or Smartpy.
We write a simple contract-calculator
Here we describe the whole process of creating a contract with stupids and errors in order to show where there were problems and how much this https://gagarin.news/terms-of-use/ method of programming is intuitively understandable.
In our contract there will be two entry points – Addition and Subtraction, Addition and Subtraction, respectively. When calling the entry point, the user transfers an in -type argument that the contract adds or takes away from the value to the storage.
First, add the Contract Compilation from Main Blocks – in it we set the type of storage and its original state.
Change the type of storage from UNIT on Int and set the original value 0. To do this, in the menu on the left, select the types of ints and drag the blocks to the appropriate places.
The first stupid – in the Initial Storage tried to drag the INT block from the Types menu, but it was necessary from Values. We set a meaning, not just a type.
Add two entry points, give them the names and put the type of incoming int. They need to realize the function of the type “Storage = Storage + Parameter”.
Second tupnyak – for a long time searched for Values and Types block for assigning a new value to the storage. Everything turned out to be simple: in the Variables menu, select the “Assign” block (Assign), add a storage and a mathematical operation to it, and already in it – two variables of Storage and Parameter.
In the same way we fill in the deduction function, only with minus in the function. By the way, Visualtez allows you to copy blocks with all the contents, so we just copied the block with the assignment of a new Storage value.
Now you can compile a smart contract. On Smartpy it looks like this.
Visualtez does not have Dry Run, that is, a test launch of a contract with a given incoming parameter. Therefore, we write a test: a debris of a contract, call the entrance points and give it arguments to them. In the first test we add 10, in the second – we take away 15, in the third we try to take the line “KEK” to get an error.
When testing, we first received an unplanned error of a virtual machine, because we forgot about an important thing: Michelson does not know how to lines and need to be transferred to a byte format. Therefore, the line “KEK” was replaced with a natural number 0, and our contract successfully passed tests.
Seriously, try Visualtez
In general, we are satisfied with the result and experience with Visualtez . The only thing that is a little confusing is almost the same background for a common workshop with a contract and a block selection menu. For example, when you press Main Blocks, you might think for a few seconds that you added four available blocks to the screen at once.
It was much easier and faster than we expected to assemble a contract in Visualtez. If you have previously tried to develop on LIGO or Smartpy, but threw it because of the complexity-try to write something in Visualtez. You’ll like it.
If you are an experienced developer, also try. Visualtez may suit you as a tool for prototyping or experiments.
Subscribe to the social networks Tezos Ukraine so as not to miss anything:
No Comments