File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11module MyToken ::coin {
2+ use 0x1 ::signer;
23
3- use 0x1 ::signer;
4-
5- /// Resource that represents a simple token
4+ /// Simple in-memory coin (educational)
65 struct Coin has store { value: u64 }
76
87 const EINSUFFICIENT_BALANCE : u64 = 1 ;
98
10- /// Mint new tokens
11- public fun mint (owner: &signer , amount: u64 ): Coin {
9+ public fun mint (_owner: &signer , amount: u64 ): Coin {
1210 Coin { value: amount }
1311 }
1412
15- /// Get balance
1613 public fun balance (coin: &Coin ): u64 {
1714 coin.value
1815 }
1916
20- /// Transfer tokens
2117 public fun transfer (from: &mut Coin , amount: u64 ): Coin {
2218 assert ! (from.value >= amount, EINSUFFICIENT_BALANCE );
2319 from.value = from.value - amount;
2420 Coin { value: amount }
2521 }
2622
27- /// Burn tokens
2823 public fun burn (coin: Coin ): u64 {
2924 let amount = coin.value;
3025 amount
You can’t perform that action at this time.
0 commit comments