We’ve been hard at work to make developing smart contracts on Zilliqa easier and more intuitive. This is the first of an upcoming series of tutorials on how to develop for Zilliqa with our new tools. If there is anything you want to learn more of, let us know in the comments!
Kicking off the development of smart contracts can be a hassle, as there are several tools that you have to install even before you can even start coding. You also need to keep updated with any tools that change midway during development. In order to make developing smart contracts more painless, we have launched a web-based Interactive Development Environment (IDE) that comes with all the necessary features required to manually create and test contracts.
This web IDE is created by Ovidiu Miclea and it can be found at https://ide.zilliqa.com/.
This web IDE will also be the primary portal for learning Scilla, a safe-by-design smart contract language designed for Zilliqa. Scilla is a principled domain-specific language that has security features and best practices built-in. You can learn more about why we created a new language and Scilla’s design principles here.
Features included in this IDE:
- Persistent Memory: All contract codes and contract states are stored within your browser’s cookies until you clear them with the IDE’s
- Testing Accounts: The IDE is equipped with 20 different accounts that are preloaded with 1 billion test ZIL tokens. You can use these accounts to
Callcontracts written in the IDE and check if your contracts are working as intended.
- Automatic Filtering of Transitions (i.e. Functions/Methods): Filters out the callable transitions available within the contract automatically after you deploy it.
- Static Type Checking: Type-check for errors in variables within your contract on-the-fly and ensure that the contract is Type-Safe before deployment.
- Automatic Block-time: This IDE simulates a blockchain (literally a chain of blocks with timestamp on them) and sets an arbitrary block interval at 10 seconds each. You can use this block-time as your timestamp for your time-lock or escrow contracts.
The steps for developing a new smart contract typically goes like this:
 Create new Scilla file by using
+ NEW CONTRACT and name your project.
 Code in Scilla, by referencing documentation or the sample contracts available on the left tab.
CHECK your contract for type and syntax errors.
 Debug using the red error pointers highlighted in the coding environment.
 Choose an arbitrary account.
 At the
DEPLOY tab, key in the initial parameter (and immutable variables if any) of the contract.
DEPLOY the contract.
 Choose an arbitrary account.
 At the
CALL tab, key in the message parameters (and mutable variables if any) to pass to the transition of the contract.
CALL the contract.
 At the
STATE tab, check the previous and final states of the contract to see if the logic flow is correct.
 Repeat step 5 to step 11 for each test case of your smart contract.
- Events are emitted if your transition includes it. It is recommended to use events for the checking of the logical flow of your contract. You can check out the CrowdFunding sample contract to understand how to write an event within your transition.
Walkthrough of a Simple HelloWorld contract deployment
A smart contract can, generally, be viewed as the code for accessing a highly-secured and immutable database. It is typically used to store important information, such as ownership and total supply, on the blockchain.
When the smart contract is deployed on the blockchain, its state is initialised. The contract state will then only mutate when a user with the right permissions calls a transition (function) within the smart contract. Note that every transaction that changes the contract state cannot be reversed on a blockchain.
There are two forms of variables in a smart contract that can be stored on the blockchain:
- Immutable variables that do not change throughout the lifespan of the contract, as declared within the parenthesis
- Mutable variables, as declared with
In this HelloWorld Contract example, we have an immutable variable of type
owner, that stores the owner’s account address. It does not change throughout the lifespan of the contract. We also have a mutable variable of type
String, which changes only when the owner of the contract invokes the
To deploy this HelloWorld contract, we simply need to key in the
owner field as the initial parameters. To call the deployed contract, we just need to define the message parameters for
Hope this quick walkthrough was a helpful introduction to building a simple smart contract on our new IDE. If you have any questions, you can find us on Gitter or let us know in the comments. Stay tuned to more tutorials and tool walkthroughs coming up soon!