- Notifications
You must be signed in to change notification settings - Fork78
Scilla - A Smart Contract Intermediate Level Language
License
Zilliqa/scilla
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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.
A comprehensive documentation on Scilla, its features and constructs can be foundhere
If you don't want to setup and build Scilla from source, skip this section to follow the opam installation instructions.
We suggest users to use the latest release of Scilla availablehere.
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/
Platform specific instructions for setting up your system for building Scilla can befound inINSTALL.md.
To build the project from the root folder:
make
Scilla can be installed into your opam switch as
make install
and can similarly be uninstalled as
make uninstall
Scilla can be installed using OCaml's package manageropam
.
To install the development version of Scilla package make sure you are usingthe correct opam switch and execute the following
opam pin add scilla git+https://github.com/Zilliqa/scilla#master --yes
cd<scilla-repo># It is important to pick the right git branch because opam pins the package to the current branchgit checkout masteropam install ./scilla.opam
If you are using a local opam switch (seehere)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
Once the project is built you can try the following things:
From the project root, execute
eval-runner -gaslimit 10000 -libdir src/stdlib tests/eval/good/let.scilexp
Instead oflet.scilla
you might want to try any different file intests/eval
. The second argument, which is a path to the Scillastandard library can alternatively be specified in the environmentvariableSCILLA_STDLIB_PATH
. This must be an absolute path (or alist of paths separated with:
(or;
on Windows).
From the project root, execute
scilla-checker -gaslimit 10000 -libdir src/stdlib tests/contracts/auction.scilla
Instead ofauction.scilla
you might want to try any different file intests/contracts
with a complete implementation of a contract, or yourown contract code. The second argument, which is a path to the Scillastandard library can alternatively be specified in the environmentvariableSCILLA_STDLIB_PATH
. As above, this must be an absolutepath(s).
If the checker only returns the contract structure in JSON format, itmeans that the contract has no type errors. Otherwise, a type errortrace is provided.
The checker can be run with the following optional flags:
-cf
to enable the cashflow checker and print its results.
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 theeasyrun.sh
script as below:
./easyrun.sh crowdfunding 1
wheren
is a number0-5
for the number of "steps" to execute theprotocol (the messages and blockchain states are provided for only somany steps in the simulation).
Ascilla-server
is provided that provides the functionality ofscilla-runner
andscilla-checker
as a JSON-RPC server. Thescilla-server
process acceptscontract execution requests and executes the contract, providing a JSON outputwithin the server process itself.
More details on the protocol can be foundhere.
For local testing and experiments, ascilla-client
is also provided on developmentbuilds (make dev
). This can interact withscilla-server
, achieving the same effectasscilla-runner
andscilla-client
.
Startscilla-server
without any arguments. Examples for checking a contractand running a transition viascilla-server
are provided below. They are to berun on a separate shell (whilescilla-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"
- The runnables are put into the folder
$PROJECT_DIR/bin
An emacs major mode for editing Scilla contracts isprovided.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 (seeINSTALL.md). Whenscilla-checker
is available,type reporting is also supported. The key bindingC-c C-t
will print the type of the variable on whichthe 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")
Visual Studio Code support for Scilla is available.Github SourceYou can install it through:https://marketplace.visualstudio.com/items?itemName=as1ndu.scilla
Credits:as1ndu
About
Scilla - A Smart Contract Intermediate Level Language