twist/protocols/tokens/twisto.twml
Hellings 4f68bc964b
Some checks failed
Build and publish / verify (push) Has been cancelled
Build and publish / publish (push) Has been cancelled
fix(ci): Use GitHub ref for setup-java.
2026-09-12 08:38:52 -04:00

40 lines
1.1 KiB
Text

contract Twisto {
fun initialize(metadata, supply, cap) =
if load(0) == 0 then
let ignored = store(0, caller) in
let ignored = store(1, metadata) in
let ignored = store(2, cap) in
let ignored = store(3, supply) in
store(caller, supply)
else 0;
fun metadata() = load(1);
fun total_supply() = load(3);
fun cap() = load(2);
fun balance_of(account) = load(account);
fun transfer(to, amount) =
let from = caller in
let balance = load(from) in
if amount > balance then 0 else
let ignored = store(from, balance - amount) in
store(to, load(to) + amount);
fun mint(to, amount) =
let owner = load(0) in
let supply = load(3) in
let ceiling = load(2) in
if caller == owner then
if ceiling < supply + amount then 0 else
let ignored = store(3, supply + amount) in
store(to, load(to) + amount)
else 0;
fun burn(amount) =
let account = caller in
let balance = load(account) in
let supply = load(3) in
if amount > balance then 0 else
let ignored = store(account, balance - amount) in
store(3, supply - amount);
}