Skip to content

Commit 905a63b

Browse files
authored
Update my_token.move
1 parent 88863d5 commit 905a63b

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

mytoken/sources/my_token.move

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
module MyToken::coin {
2-
use std::signer;
3-
4-
/// Simple in-memory coin (educational)
2+
/// Minimal in-memory coin (no std imports)
53
struct Coin has store { value: u64 }
64

75
const EINSUFFICIENT_BALANCE: u64 = 1;
86

9-
public fun mint(_owner: &signer, amount: u64): Coin {
7+
/// Mint new tokens
8+
public fun mint(amount: u64): Coin {
109
Coin { value: amount }
1110
}
1211

13-
public fun balance(coin: &Coin): u64 { coin.value }
12+
/// Read balance
13+
public fun balance(c: &Coin): u64 { c.value }
1414

15+
/// Split amount from coin into a new coin
1516
public fun transfer(from: &mut Coin, amount: u64): Coin {
1617
assert!(from.value >= amount, EINSUFFICIENT_BALANCE);
1718
from.value = from.value - amount;
1819
Coin { value: amount }
1920
}
2021

21-
public fun burn(coin: Coin): u64 {
22-
let amount = coin.value;
23-
amount
22+
/// Burn coin and return amount
23+
public fun burn(c: Coin): u64 {
24+
let v = c.value;
25+
v
2426
}
2527
}

0 commit comments

Comments
 (0)