Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

fishapis.gno

0.76 Kb · 37 lines
 1package fishapis
 2
 3import (
 4	"chain"
 5	"chain/banker"
 6	"chain/runtime"
 7	"chain/runtime/unsafe"
 8	"crypto/sha256"
 9	"strconv"
10	"time"
11)
12
13func Version() string { return "apis-1" }
14
15func Touch(cur realm) string {
16	if !cur.Previous().IsUserCall() {
17		panic("eoa")
18	}
19	if len(unsafe.OriginSend()) != 0 {
20		panic("payment")
21	}
22	sum := sha256.Sum256([]byte("x"))
23	ms := time.Now().UnixMilli()
24	chain.Emit("Touch", "h", strconv.FormatInt(runtime.ChainHeight(), 10), "ms", strconv.FormatInt(ms, 10))
25	return strconv.Itoa(int(sum[0]))
26}
27
28func send(to address, amt int64, rlm realm) {
29	if !rlm.IsCurrent() {
30		panic("realm")
31	}
32	if amt == 0 {
33		return
34	}
35	bk := banker.NewBanker(banker.BankerTypeRealmSend, rlm)
36	bk.SendCoins(rlm.Address(), to, chain.Coins{{Denom: "ugnot", Amount: amt}})
37}