• Stars
    star
    242
  • Rank 167,048 (Top 4 %)
  • Language
    OCaml
  • License
    GNU General Publi...
  • Created almost 7 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Scilla - A Smart Contract Intermediate Level Language

Scilla: A Smart Contract Intermediate Level Language

Build Status License Discord chat Coverage Status

Introduction

Scilla short for Smart Contract Intermediate-Level LAnguage is an intermediate-level smart contract language being developed for Zilliqa. Scilla has been designed as a principled language with smart contract safety in mind.

Scilla imposes a structure on smart contracts that will make applications less vulnerable to attacks by eliminating certain known vulnerabilities directly at the language-level. Furthermore, the principled structure of Scilla will make applications inherently more secure and amenable to formal verification.

Zilliqa - the underlying blockchain platform on which Scilla contracts are run, has been designed to be scalable. It employs the idea of sharding to validate transactions in parallel. Zilliqa has an intrinsic token named Zilling, ZIL for short that are required to run smart contracts on Zilliqa.

Language Reference

A comprehensive documentation on Scilla, its features and constructs can be found here

Building Scilla

If you don't want to setup and build Scilla from source, skip this section to follow the opam installation instructions.

1. Cloning source code

We suggest users to use the latest release of Scilla available here.

If you'd like to hack on Scilla, clone it with all of its submodules:

git clone --jobs 4 --recurse-submodules https://github.com/Zilliqa/scilla/

2. Build prerequisites

Platform specific instructions for setting up your system for building Scilla can be found in INSTALL.md.

3. Compiling

To build the project from the root folder:

make

Installation

Scilla can be installed into your opam switch as

make install

and can similarly be uninstalled as

make uninstall

Installing Scilla with opam

Scilla can be installed using OCaml's package manager opam.

Installing Scilla from GitHub

To install the development version of Scilla package make sure you are using the correct opam switch and execute the following

opam pin add scilla git+https://github.com/Zilliqa/scilla#master --yes

Installing Scilla from your local repo

cd <scilla-repo>
# It is important to pick the right git branch because opam pins the package to the current branch
git checkout master
opam install ./scilla.opam

If you are using a local opam switch (see here) in your local Scilla repo (~/path/to/scilla), then most likely you will want to reuse the same local switch for your Scilla-based project. To do that create a symlink _opam as follows:

cd <scilla-based-project-repo>
ln -s ~/path/to/scilla/_opam _opam

Running the binary

Once the project is built you can try the following things:

Evaluating a standalone closed expression:

From the project root, execute

eval-runner -gaslimit 10000 -libdir src/stdlib tests/eval/good/let.scilexp

Instead of let.scilla you might want to try any different file in tests/eval. The second argument, which is a path to the Scilla standard library can alternatively be specified in the environment variable SCILLA_STDLIB_PATH. This must be an absolute path (or a list of paths separated with : (or ; on Windows).

Type-checking a contract

From the project root, execute

scilla-checker -gaslimit 10000 -libdir src/stdlib tests/contracts/auction.scilla

Instead of auction.scilla you might want to try any different file in tests/contracts with a complete implementation of a contract, or your own contract code. The second argument, which is a path to the Scilla standard library can alternatively be specified in the environment variable SCILLA_STDLIB_PATH. As above, this must be an absolute path(s).

If the checker only returns the contract structure in JSON format, it means that the contract has no type errors. Otherwise, a type error trace is provided.

The checker can be run with the following optional flags:

  • -cf to enable the cashflow checker and print its results.

Executing a simple transition

From the project root, execute

scilla-runner -init tests/runner/crowdfunding/init.json -istate tests/runner/crowdfunding/state_4.json -iblockchain tests/runner/crowdfunding/blockchain_4.json -imessage tests/runner/crowdfunding/message_4.json -o tests/runner/crowdfunding/output_4.json -i tests/contracts/crowdfunding.scilla -libdir src/stdlib -gaslimit 8000

or

scilla-runner -init tests/runner/zil-game/init.json -istate tests/runner/zil-game/state_5.json -iblockchain tests/runner/zil-game/blockchain_5.json -imessage tests/runner/zil-game/message_5.json -o tests/runner/zil-game/output_5.json -i tests/contracts/zil-game.scilla -libdir src/stdlib -gaslimit 8000

If you'd like to see the output produced by the aforementioned commands, check the file specified by -o path/to/file.json argument.

Alternatively, use the easyrun.sh script as below:

./easyrun.sh crowdfunding 1

where n is a number 0-5 for the number of "steps" to execute the protocol (the messages and blockchain states are provided for only so many steps in the simulation).

Using Scilla as a service

A scilla-server is provided that provides the functionality of scilla-runner and scilla-checker as a JSON-RPC server. The scilla-server process accepts contract execution requests and executes the contract, providing a JSON output within the server process itself.

More details on the protocol can be found here.

For local testing and experiments, a scilla-client is also provided on development builds (make dev). This can interact with scilla-server, achieving the same effect as scilla-runner and scilla-client.

Start scilla-server without any arguments. Examples for checking a contract and running a transition via scilla-server are provided below. They are to be run on a separate shell (while scilla-server continues to run).

scilla-client run -argv " -init tests/runner/crowdfunding/init.json -istate tests/runner/crowdfunding/state_4.json -iblockchain tests/runner/crowdfunding/blockchain_4.json -imessage tests/runner/crowdfunding/message_4.json -o tests/runner/crowdfunding/output_4.json -i tests/contracts/crowdfunding.scilla -libdir src/stdlib -gaslimit 8000"

scilla-client check -argv " -libdir src/stdlib -gaslimit 8000 tests/contracts/helloWorld.scilla"

Where to find binaries

  • The runnables are put into the folder
$PROJECT_DIR/bin

Developer Tools

Emacs mode

An emacs major mode for editing Scilla contracts is provided. Add the following line to your .emacs file to load this mode for files ending with .scilla and .scillib. For enabling flycheck mode for Scilla (see INSTALL.md). When scilla-checker is available, type reporting is also supported. The key binding C-c C-t will print the type of the variable on which the cursor currently is.

;; For enabling flycheck mode for Scilla.
(setq scilla-root "/path/to/scilla/root")
;; Scilla mode
(load-file "/path/to/scilla-mode.el")

VSCode Plugin

Visual Studio Code support for Scilla is available. Github Source You can install it through:https://marketplace.visualstudio.com/items?itemName=as1ndu.scilla

Credits: as1ndu

More Repositories

1

Zilliqa

Zilliqa is the world's first high-throughput public blockchain platform - designed to scale to thousands โ€‹of transactions per second.
C++
1,131
star
2

zilliqa-js

JavaScript SDK for Zilliqa blockchain
TypeScript
127
star
3

ZRC

Zilliqa Reference Contracts
JavaScript
39
star
4

kaya

RPC Server for Zilliqa
JavaScript
39
star
5

gozilliqa-sdk

Zilliqa golang sdk
Go
33
star
6

scilla-coq

State-Transition Systems for Smart Contracts
Coq
23
star
7

Zilliqa-old-testnet-Wallet-Archived

Zilliqa old testnet wallet (Archived)
TypeScript
23
star
8

ZIP

Zilliqa Improvement Proposal
22
star
9

Zilliqa-ERC20-Token

Zilliqa Token Generation
JavaScript
21
star
10

staking-contract

This repository is the central portal that collates together the contracts, documentations around them, unit tests, and scripts to deploy and run the contracts on the network.
Go
19
star
11

learn-scilla

๐Ÿ’กAn interactive tutorial for people to learn Scilla through a gamification process.
TypeScript
19
star
12

scilla-docs

Documentation for Scilla
17
star
13

dev-portal

Documentation for Zilliqa developer
JavaScript
16
star
14

docs

Zilliqa public documents repository
HTML
15
star
15

dev-wallet

Nucleus Wallet is a free, open-source, Zilliqa Testnet Wallet.
TypeScript
14
star
16

devex

Devex
TypeScript
10
star
17

zilliqa-unity-sdk

Zilliqa's Unity3D SDK
C#
10
star
18

ceres

Ceres is a graphical user interface that runs different Zilliqa development tools under Docker containers without the need of user knowing how to use docker or run it's commands. You can focus on Scilla development while Ceres manages Zilliqa Tools for you.
Vue
9
star
19

zilliqa-rosetta

Go
8
star
20

scilla-rtl

Execute Scilla code compiled by the Scilla -> LLVM compiler.
C++
8
star
21

scilla-compiler

Compile Scilla to LLVM-IR
OCaml
7
star
22

zilliqa-social-pay

TypeScript
6
star
23

scilla-mode

Emacs support for the Scilla programming language
Emacs Lisp
4
star
24

goduplicator

Go
3
star
25

schnorr

C++
3
star
26

zilhub

3
star
27

zli

Zilliqa's command line tool based on gozilliqa-sdk
Go
3
star
28

zilwrap-sdk

TypeScript
3
star
29

apidocs

JSON RPC Documentation for Zilliqa
JavaScript
3
star
30

dev-portal-examples

JavaScript
3
star
31

zilliqa-developer

Java
3
star
32

scilla-workshop

Documents and code for Scilla workshops and similar events
Shell
2
star
33

marketplace-contracts

JavaScript
2
star
34

zilliqa-multisig-wallet

zilliqa multisig wallet
Vue
2
star
35

hardhat-scilla-plugin

TypeScript
2
star
36

Scilla-Cookbook

Scilla Cookbook. Be a Scilla Chef
JavaScript
2
star
37

zilliqa-bounties

Bounties to work on zilliqa related projects.
2
star
38

Zilliqa-JavaScript-Library-Examples

JavaScript
2
star
39

scilla-json-utils

Scilla JSON utils
TypeScript
2
star
40

zilliqa-isolated-server

Dockerized Zilliqa Isolated Server
Shell
1
star
41

zilliqa-exporter

export zilliqa metrics to prometheus
Go
1
star
42

Zilliqa-Release

Release Zilliqa and Scilla binary
1
star
43

staking-calculator-plugin

pure javascript plugin that calculates staking rewards
JavaScript
1
star
44

cryptoutils

C++
1
star
45

wrappedZIL

1
star
46

faucet-service

Go
1
star
47

ZILScamWatchlist

Zilliqa scam watchlist
JavaScript
1
star
48

TokenSwapContract

For housing token swapping contracts
Solidity
1
star