Tealang - high level language for Algorand ASC1 and TEAL
High-level language for Algorand Smart Contracts at Layer-1 and its low-level TEAL v6 language. The goal is to abstract the stack-based Algorand Virtual Machine and provide imperative Go/JS/Python-like syntax.
Integer and bytes types
Variables and constants
let var1 = 1
let var2 = 0x123
const myaddr = addr"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ"
let a = (1 + 2) / 3
let b = ~a
inline function sample1(a) {
return a - 1
}
function sample2(a) {
return a + 1
}
function noop() void {
return
}
function logic() {
return sample1(2) + sample2(3)
}
function condition(a) {
let b = if a == 1 { 10 } else { 0 }
if b == 0 {
return a
}
return 1
}
let y= 2;
for y>0 { y=y-1 }
function get_string() {
return "\x32\x33\x34"
}
function logic() {
let a = 1
a = get_string() // <- type check error
return a
}
function approval() {
let x = accounts[1].Balance
return 1
}
function logic() {
let s = global.GroupSize
let idx = 1
let a = gtxn[s-1].ApplicationArgs[idx+2];
return a != "\x01"
}
import stdlib.const
Check the language documentation!
Tealang to bytecode
tealang mycontract.tl -o mycontract.tok
Tealang to TEAL
tealang -c mycontract.tl -o mycontract.teal
Tealang logic one-liner to bytecode
tealang -l '(txn.Sender == "abc") && global.MinTxnFee > 2000' -o mycontract.tok
stdin to stdout
cat mycontract.tl | tealang -s -r - > mycontract.tok
Dryrun / trace
tealang -s -c -d '' examples/basic.tl
make antlr-install
Refer to the documentation in case of problems.go get -u github.com/antlr/antlr4/runtime/Go/antlr
make algorand-install
Check the Algorand README for detailed build instructions if encounter any issues.make && make test
make java-gui ARGS=examples/basic.tl
load
.