-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathcontract.tact
44 lines (37 loc) · 1.32 KB
/
contract.tact
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import "./jetton";
message Mint {
amount: Int;
receiver: Address;
}
contract SampleJetton with Jetton {
total_supply: Int as coins;
owner: Address;
content: Cell;
mintable: Bool;
max_supply: Int as coins; // Extract parameter we set here. The Jetton Standards doesn't have this parameter.
init(owner: Address, content: Cell, max_supply: Int) {
self.total_supply = 0;
self.owner = owner;
self.mintable = true;
self.content = content;
self.max_supply = max_supply;
}
receive(msg: Mint) {
let ctx: Context = context();
require(ctx.sender == self.owner, "Not owner");
require(self.mintable, "Not mintable");
require(self.total_supply + msg.amount <= self.max_supply, "Max supply exceeded");
self.mint(msg.receiver, msg.amount, self.owner); // (to, amount, response_destination)
}
receive("Mint: 100") { // Public Minting
let ctx: Context = context();
require(self.mintable, "Not mintable");
require(self.total_supply + 100 <= self.max_supply, "Max supply exceeded");
self.mint(ctx.sender, 100, self.owner); // 🔴
}
receive("Owner: MintClose") {
let ctx: Context = context();
require(ctx.sender == self.owner, "Not owner");
self.mintable = false;
}
}