Created
July 7, 2020 12:41
-
-
Save dakk/e5ce0a24bc0688b37326f016c9218d5d to your computer and use it in GitHub Desktop.
yallo_medium_1_contract.yallo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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