Skip to content

Instantly share code, notes, and snippets.

@dakk
Created July 7, 2020 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dakk/e5ce0a24bc0688b37326f016c9218d5d to your computer and use it in GitHub Desktop.
Save dakk/e5ce0a24bc0688b37326f016c9218d5d to your computer and use it in GitHub Desktop.
yallo_medium_1_contract.yallo
contract Token implements IToken {
field balances: (address, nat) big_map;
field totalSupply: nat;
field symbol: string;
constructor (owner: address, supply: nat, symbol: string) {
this.balances = [ { owner: supply } ];
this.totalSupply = supply;
this.symbol = symbol;
}
entry transfer(from: address, to: address, val: nat) {
let a: nat = this.balances.get(from, 0n);
let b: nat = this.balances.get(to, 0n);
assert (a >= val);
this.balances.update(from, a - val);
this.balances.update(to, b + val);
[]
}
view getBalance(ad: address): nat {
this.balances.get(ad, 0n)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment