Skip to content

Smart Contract Language

Sean Batzel edited this page Dec 2, 2019 · 6 revisions

In order to carry out general computing and value-moving requirements, including the proof-of-stake algorithm, the blockchain simulator will include a simple smart contract system. The smart contracts will provide functions for simple programming structures, and will allow for transferring tokens between accounts.

Syntax

The smart contract language for this blockchain will be a fairly easily-assembled low-level language that will carry instructions for calculations in the following grammar:

.<label>
<instr>
<instr> <arg>
<instr> <arg> <arg>
<instr> <arg> <arg> <arg>

Language Reference

Code Instruction Argument Description
0 nop None No operation.
1 mov 'to' memory address, 'from' memory address Move memory values.
2 trn token volume, 'to' account, 'from' account Transfer tokens from one account to another.
3 sav memory address, storage address Save a value to permanent storage.
4 lod memory address, storage address Load a value from permanent storage.
5 add address, value Add a value to a given memory location.
6 sub address, value Subtract from a given memory location.
7 mul address, value Multiply a given memory location by a value.
8 jlt x, y, label Jump to label if x is less than y.
9 jgt x, y, label Jump to a label if x is greater than y.
10 jeq x, y, label Jump to a label if x is equal to y.
11 jmp label Jump unconditionally to a label.
12 ret x Returns the value in memory address x.
13 act None Creates a new account on the chain.
14 bal acct Retrieve a balance given an account name.
Clone this wiki locally