Skip to content

Commit 8bc9d48

Browse files
author
rpfister102
authored
Merge pull request #87 from bazo-blockchain/examples
Update SimpleContract example with available features
2 parents f2f76f3 + eb75c65 commit 8bc9d48

File tree

4 files changed

+45
-21
lines changed

4 files changed

+45
-21
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ addons:
1212

1313
script:
1414
- go test -v ./... -coverprofile=coverage.out -coverpkg=./...
15-
- go run main.go run program.lazo
15+
- go run main.go run examples/SimpleContract.lazo
1616
- sonar-scanner
1717

1818
after_success:

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,38 @@ into the Bazo Byte Code for the [Bazo Virtual Machine](https://github.com/bazo-b
4242
V
4343
Bazo Byte Code
4444

45+
46+
## Result
47+
48+
* Link to technical documentation (Bachelor Thesis 2019)
49+
* 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)
50+
51+
## Lazo Example
52+
53+
Note: Lazo is still under development. The example below contains only the currently available features.
54+
Please see [lazo-specification/examples](https://github.com/bazo-blockchain/lazo-specification/tree/master/examples)
55+
for real smart contract use cases.
56+
57+
```csharp
58+
contract SimpleContract {
59+
Map<int, int> balances
60+
61+
constructor() {
62+
balances[0x01] = 10
63+
balances[0x02] = 2
64+
65+
pay(0x01, 0x02, 5)
66+
}
67+
68+
function void pay(int from, int to, int amount) {
69+
if (amount > 0 && balances[from] >= amount){
70+
balances[from] -= amount
71+
balances[to] += amount
72+
}
73+
}
74+
}
75+
```
76+
4577
## Usage
4678

4779
The Lazo tool works with the CLI commands.

examples/SimpleContract.lazo

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
contract SimpleContract {
2-
int x
3-
int y = 1
4-
bool b
5-
string s = "test"
2+
Map<int, int> balances
63

7-
function bool calc(int a, int b) {
8-
x = y
9-
y = a + b
4+
constructor() {
5+
balances[0x01] = 10
6+
balances[0x02] = 2
107

11-
return a > b
8+
pay(0x01, 0x02, 5)
9+
}
10+
11+
function void pay(int from, int to, int amount) {
12+
if (amount > 0 && balances[from] >= amount){
13+
balances[from] -= amount
14+
balances[to] += amount
15+
}
1216
}
1317
}

program.lazo

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)