https://github.com/bazo-blockchain/lazo
Lazo - A Smart Contract Language for the Bazo Blockchain
https://github.com/bazo-blockchain/lazo
blockchain compiler language smartcontract
Last synced: 4 months ago
JSON representation
Lazo - A Smart Contract Language for the Bazo Blockchain
- Host: GitHub
- URL: https://github.com/bazo-blockchain/lazo
- Owner: bazo-blockchain
- License: mit
- Created: 2019-02-19T19:41:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-05T17:37:47.000Z (about 7 years ago)
- Last Synced: 2025-10-09T10:00:58.158Z (9 months ago)
- Topics: blockchain, compiler, language, smartcontract
- Language: Go
- Size: 559 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lazo: A Smart Contract Language for the Bazo Blockchain
[](https://travis-ci.org/bazo-blockchain/lazo)
[](https://sonarcloud.io/dashboard?id=bazo-blockchain_lazo)
[](https://sonarcloud.io/dashboard?id=bazo-blockchain_lazo)
[](https://goreportcard.com/report/github.com/bazo-blockchain/lazo)
[](https://godoc.org/github.com/bazo-blockchain/lazo)
Lazo is a statically typed, imperative and non-turing complete programming language.
Please refer to [lazo-specification](https://github.com/bazo-blockchain/lazo-specification) for the complete language features.
## Background
The Bazo Blockchain is a research blockchain to test different mechanisms and algorithms.
In the current version, there is a virtual machine available to interpret and execute IL codes on the Bazo Blockchain.
The goal of this bachelor thesis is to build a compiler, which compiles the smart contracts written in the Lazo language
into the Bazo Byte Code for the [Bazo Virtual Machine](https://github.com/bazo-blockchain/bazo-vm).
Lazo Source Code
|
V
+---------------+
| Lexer |
+---------------+
|
V
+---------------+
| Parser |
+---------------+
|
V
+---------------+
| Checker |
+---------------+
|
V
+---------------+
| Generator |
+---------------+
|
V
Bazo Byte Code
## Result
* Technical Documentation for [Lazo Compiler](https://github.com/bazo-blockchain/lazo/releases/download/v0.5.0/Lazo.pdf) (Bachelor Thesis 2019)
* Complete [Language Specification v1.0](https://eprints.hsr.ch/736/1/HS%202018%202019-SA-EP-Pfister-THURAIRATNAM-Improving%20the%20Bazo%20Blockchain.pdf) (Term Project 2018)
## Lazo Example
Note: Lazo is still under development. The example below contains only the currently available features.
Please see [lazo-specification/examples](https://github.com/bazo-blockchain/lazo-specification/tree/master/examples)
for real smart contract use cases.
```csharp
contract SimpleContract {
Map balances
constructor() {
balances[0x01] = 10
balances[0x02] = 2
pay(0x01, 0x02, 5)
}
function void pay(int from, int to, int amount) {
if (amount > 0 && balances[from] >= amount){
balances[from] -= amount
balances[to] += amount
}
}
}
```
## Usage
The Lazo tool works with the CLI commands.
Run `lazo` to see all the available commands and their usages.
$ lazo
Lazo is a tool for managing Lazo source code on the Bazo Blockchain
Usage:
lazo [flags]
lazo [command]
Available Commands:
compile Compile the Lazo source code
help Help about any command
run Compile and run the lazo source code on Bazo VM
version Print the version number of Lazo
Flags:
-h, --help help for lazo
Use "lazo [command] --help" for more information about a command.
Example:
* `lazo compile program.lazo`: Compile the source file *program.lazo* through all stages into Bazo byte code.
* `lazo compile program.lazo --stage=p`: Compile the source code only until the parser stage.
* `lazo run program.lazo`: Compile the source file and execute generated byte code on Bazo VM
## Development
Run `./scripts/set-hooks.sh` to setup git hooks.
### Dependency Management
Packages are managed by [Go Modules](https://github.com/golang/go/wiki/Modules).
Set the environment variable `GO111MODULE=on` and run `go mod vendor`
to install all the dependencies into the local vendor directory.
### Run Compiler from Source
go run main.go compile program.lazo
It will compile the given source code file "*program.lazo*".
### Run Unit Tests
go test ./...
It will run all tests in the current directory and all of its subdirectories.
To see the test coverage, run `./scripts/test.sh` and then open the **coverage.html** file.
### Run Lints
./scripts/lint.sh
It will run golint on all packages except the vendor directory.
### Build Compiler
go build
It will create an executable for the current operating system (e.g. `lazo.exe` in Windows).
### Install Compiler
go install
It will build an executable and place it in the `$GOPATH/bin` directory.
Thus, `lazo` command will be available in the terminal from anywhere.