Transaction
87DCCA07ADA115…E7C1863E1C5F
Block 26,013 · index 0 · indexed
Summary
- Hash
- 87DCCA07ADA115F0913979193A89164A09B7F10485C195045C4EE7C1863E1C5F
- Block
- 26,013
- Size
- 5568 bytes
- Gas used
- 10,188,535 / 12,226,302
- Fee
- 1000000ugnot
- Memo
- gnopublish
- Status
- success
Messages
Arguments · 9
- #1eightball
- #2README.md
- #3# 🎱 Magic 8-Ball > ⚠️ **Experimental — generated with no human supervision.** This realm was produced > by an MCP-driven agent to exercise the gno MCP server + tooling and to generate > test content for gno compilers, linters and formatters. **Not audited. Not for > production.** Full context & folder README: > [r/moul/x/daily](https://github.com/moul/gno-contracts/blob/main/r/moul/x/daily/README.md) --- A classic Magic 8-Ball as a gno.land realm. Ask a yes/no question and the current **block height** picks one of the 20 canonical answers — fully deterministic, since there is no true randomness on-chain. - `Ask(cur realm, question string) string` — records `{caller, question, answer, height}` and returns the answer (crossing function; emits a `Shaken` event). - `Asked() int` — how many questions have been asked (read-only). - `Render(path string) string` — shows the last answer and a table of recent shakes. Built for the sapphire testnet (gno `0.9`). Example: ``` gnokey maketx call -pkgpath gno.land/r/moul/x/daily/eightball/v0 \ -func Ask -args "will this PR pass CI?" ... ``` <!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) --> --- Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage. > 🧪 **Highly experimental — potentially vibe-coded.** Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: [DISCLAIMER](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md). <!-- END GNOCONTRACTS FOOTER -->
- #4eightball.gno
- #5// Package eightball is a Magic 8-Ball realm: ask a yes/no question and the // block height decides your fate. Deterministic (no real randomness on-chain). package eightball import ( "chain" "chain/runtime" "chain/runtime/unsafe" "strconv" "strings" ) // The 20 classic Magic 8-Ball answers. var answers = []string{ "It is certain.", "It is decidedly so.", "Without a doubt.", "Yes definitely.", "You may rely on it.", "As I see it, yes.", "Most likely.", "Outlook good.", "Yes.", "Signs point to yes.", "Reply hazy, try again.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don't count on it.", "My reply is no.", "My sources say no.", "Outlook not so good.", "Very doubtful.", } type shake struct { asker string question string answer string height int64 } var history []shake // answerIndex maps (block height, prior shakes) to an answer slot. Pure and // deterministic so it can be tested without touching realm state. func answerIndex(height int64, n int) int { i := (height + int64(n)) % int64(len(answers)) if i < 0 { i += int64(len(answers)) } return int(i) } // Ask poses a question to the Magic 8-Ball and returns its answer. Crossing // function: it mutates persistent state, so it takes `cur realm` (gno 0.9). func Ask(cur realm, question string) string { question = strings.TrimSpace(question) if question == "" { panic("question must not be empty") } if len(question) > 200 { panic("question too long (max 200 chars)") } h := runtime.ChainHeight() ans := answers[answerIndex(h, len(history))] history = append(history, shake{ asker: unsafe.PreviousRealm().Address().String(), question: question, answer: ans, height: h, }) chain.Emit("Shaken", "answer", ans, "height", strconv.FormatInt(h, 10)) return ans } // Asked returns how many questions have been asked. Read-only. func Asked() int { return len(history) } // Render is the gnoweb Markdown view. func Render(path string) string { var b strings.Builder b.WriteString("# 🎱 Magic 8-Ball\n\n") b.WriteString("> ⚠️ Experimental, auto-generated with no human supervision (MCP test corpus). ") b.WriteString("Not audited. See [r/moul/x/daily](https://github.com/moul/gno-contracts/blob/main/r/moul/x/daily/README.md).\n\n") b.WriteString("Ask a yes/no question — the block height decides your fate.\n\n") b.WriteString("**Questions asked:** ") b.WriteString(strconv.Itoa(len(history))) b.WriteString("\n\n") if len(history) == 0 { b.WriteString("_No questions yet. Call `Ask(\"will it rain tomorrow?\")`._\n") return b.String() } last := history[len(history)-1] b.WriteString("Last shake: 🎱 _") b.WriteString(last.answer) b.WriteString("_\n\n| # | asker | question | answer | height |\n") b.WriteString("|---|---|---|---|---|\n") start := len(history) - 1 end := start - 14 if end < 0 { end = 0 } for i := start; i >= end; i-- { e := history[i] b.WriteString("| ") b.WriteString(strconv.Itoa(i + 1)) b.WriteString(" | ") b.WriteString(shortAddr(e.asker)) b.WriteString(" | ") b.WriteString(e.question) b.WriteString(" | ") b.WriteString(e.answer) b.WriteString(" | ") b.WriteString(strconv.FormatInt(e.height, 10)) b.WriteString(" |\n") } return b.String() } func shortAddr(a string) string { if len(a) <= 13 { return a } return a[:8] + "…" + a[len(a)-4:] }
- #6gnomod.toml
- #7module = "gno.land/r/moul/x/daily/eightball/v0" gno = "0.9"
- #8/gno.MemPackageType
- #9 MPUserProd
Result log
msg:0,success:true,log:,events:[]