-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmotoko1.mo
More file actions
40 lines (30 loc) · 830 Bytes
/
Copy pathmotoko1.mo
File metadata and controls
40 lines (30 loc) · 830 Bytes
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
//imports
import Nat "mo:base/Nat";
import Nat64 "mo:base/Nat64";
import Cycles "mo:base/ExperimentalCycles";
//canisters
actor HelloCycles {
//variables
//let => immutable
//var => mutable
let limit = 10_000_000;
//functions (query, update)
//":" donus bekler, async
public func wallet_balance() : async Nat {
//return -> return ... ;
//return -> ...
return Cycles.balance();
};
public func wallet_receive() : async { accepted: Nat64 } {
let available = Cycles.available();
let accepted = Cycles.accept(Nat.min(available, limit));
{ accepted = Nat64.fromNat(accepted) };
};
public func transfer(
receiver : shared () -> async (),
amount : Nat) : async { refunded : Nat } {
Cycles.add(amount);
await receiver();
{ refunded = Cycles.refunded() };
};
};