Standard Library¶
In addition to the AVM opcodes Tealish provides some builtin utility functions. All builtin Tealish functions are Capitalized to distinguish them from the AVM functions which are lowercase.
- Cast(Expression, Type) any ¶
Tells the compiler to treat the expression as the given type. The compiler adds a runtime type length assertion.
bytes[32] address = Cast(Txn.ApplicationArgs[0], bytes[32])
- UncheckedCast(Expression, Type) any ¶
Tells the compiler to treat the expression as the given type. The compiler does not add any runtime type length assertion.
bytes[32] address = UncheckedCast(Txn.ApplicationArgs[0], bytes[32])
- Concat(bytes, bytes, ...) bytes ¶
Concatenates multiple byte strings together.
bytes foo = Concat(a, b, c, d)
- Rpad(bytes, len) bytes ¶
Pads the byte string with 0 bytes (”\x00”) to the right.
bytes[10] b = Rpad("abc", 10) assert(b == "abc\x00\x00\x00\x00\x00\x00\x00")
- Lpad(bytes, len) bytes ¶
Pads the byte string with 0 bytes (”\x00”) to the left.
bytes[10] b = Lpad("abc", 10) assert(b == "\x00\x00\x00\x00\x00\x00\x00abc")
- SizeOf(Struct) int ¶
Returns the size of a
struct
type as a compile time constant.Item item1 = bzero(SizeOf(Item))
- Address(address) bytes ¶
Supports hardcoding of address constants in contracts in the standard Algorand base32 format. Note: the address must be a constant at compile time.
const TINYMAN = Address("RIKLQ5HEVXAOAWYSW2LGQFYGWVO4J6LIAQQ72ZRULHZ4KS5NRPCCKYPCUU")