Transaction

83C2225532B877…D0DFCACCF3A0

Block 26,408 · index 0 · indexed

Summary

Hash
83C2225532B877931565E06F9C38CDB054139D31AA37AB492D99D0DFCACCF3A0
Block
26,408
Size
6879 bytes
Gas used
10,559,733 / 12,671,739
Fee
1000000 ugnot
Memo
gnopublish
Status
success

Messages

#1AddPackagegno.land/r/moul/x/daily/todos/v09 arguments

Arguments · 9

  1. #1todos
  2. #2README.md
  3. #3# Shared To-Do Board > ⚠️ **Experimental — generated with no human supervision.** This realm was > produced automatically by an MCP-driven agent to exercise the gno MCP server > and 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) --- An on-chain, shared to-do list realm for the gno.land **sapphire** testnet (gno 0.9). Anyone can add an item to the board; each item records the caller's address as its author, and can be toggled open/done or removed. `Render` shows the board as Markdown checkboxes with live open/done counts, newest item first. - **Realm path:** `gno.land/r/REPLACE_ADDR/todos` (replace `REPLACE_ADDR` with your deploy address) ## Exported transactions | Function | Effect | |---|---| | `Add(text string) int` | Adds an item authored by the caller, returns its id | | `Toggle(id int)` | Flips an item between open and done | | `Remove(id int)` | Deletes an item | All three are gno 0.9 crossing functions (`cur realm` first parameter) and must be invoked with `cross(cur)` from another realm, or directly via `MsgCall`. ## Example calls ```sh # Add an item (returns the new id) gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/todos" \ -func Add -args "buy milk" -gas-fee 1000000ugnot -gas-wanted 2000000 \ -broadcast -chainid sapphire-1 -remote <rpc> mykey # Mark item #3 done (toggle) gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/todos" \ -func Toggle -args 3 -gas-fee 1000000ugnot -gas-wanted 2000000 \ -broadcast -chainid sapphire-1 -remote <rpc> mykey # Remove item #3 gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/todos" \ -func Remove -args 3 -gas-fee 1000000ugnot -gas-wanted 2000000 \ -broadcast -chainid sapphire-1 -remote <rpc> mykey ``` ## Example render output ```markdown # Shared To-Do Board 2 open · 1 done · 3 total - [ ] #3 walk dog (g1abc…) - [x] #2 buy milk (g1abc…) - [ ] #1 write realm (g1def…) ``` <!-- 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. **Dependency graph:** ![gno.land/r/moul/x/daily/todos/v0 dependency graph](https://raw.githubusercontent.com/moul/gno-contracts/main/_assets/gno.land/r/moul/x/daily/todos/v0/deps.png) > 🧪 **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 -->
  4. #4gnomod.toml
  5. #5module = "gno.land/r/moul/x/daily/todos/v0" gno = "0.9"
  6. #6todos.gno
  7. #7// Package todos is a shared, on-chain to-do board realm. // // Anyone can add an item; the caller's address is recorded as the author. // Items can be toggled (open/done) or removed. Render exposes the board as // Markdown checkboxes with open/done counts, newest item first. package todos import ( "strconv" "strings" "gno.land/p/nt/avl/v0" ) // item is one entry on the board. `address` is the uverse bech32 type — it is // persistable (unlike a `realm` value), so it is safe to store across txs. type item struct { id int text string done bool author address } var ( // items is keyed by zero-padded id string so avl iteration is ordered by id. items avl.Tree nextID int ) // Add appends a new item authored by the caller and returns its id. // // Crossing function: takes `cur realm` first (gno 0.9 interrealm convention), // authenticates with cur.IsCurrent() before trusting cur.Previous(). func Add(cur realm, text string) int { if !cur.IsCurrent() { panic("spoofed realm") } text = strings.TrimSpace(text) if text == "" { panic("todos: text must not be empty") } author := cur.Previous().Address() nextID++ id := nextID items.Set(idKey(id), &item{ id: id, text: text, done: false, author: author, }) return id } // Toggle flips the done state of the item with the given id. func Toggle(cur realm, id int) { if !cur.IsCurrent() { panic("spoofed realm") } v := items.Get(idKey(id)) if v == nil { panic("todos: item not found: #" + strconv.Itoa(id)) } it := v.(*item) it.done = !it.done } // Remove deletes the item with the given id. func Remove(cur realm, id int) { if !cur.IsCurrent() { panic("spoofed realm") } if _, removed := items.Remove(idKey(id)); !removed { panic("todos: item not found: #" + strconv.Itoa(id)) } } // idKey renders an id as a fixed-width, zero-padded key so avl.Tree's // byte-lexicographic ordering matches numeric id ordering. func idKey(id int) string { s := strconv.Itoa(id) const width = 12 if len(s) >= width { return s } return strings.Repeat("0", width-len(s)) + s } // shortAddr renders an address as "g1abc…" (first 6 chars + ellipsis). func shortAddr(a address) string { s := a.String() if len(s) <= 6 { return s } return s[:6] + "…" } // counts returns the number of open and done items. func counts() (open, done int) { items.Iterate("", "", func(_ string, v interface{}) bool { if v.(*item).done { done++ } else { open++ } return false }) return open, done } // Render returns the board as Markdown. Newest item (highest id) first. // // Render is NOT a crossing function (no `cur realm` param) — it is read-only // and invoked by gnoweb, not via MsgCall. func Render(path string) string { open, done := counts() var b strings.Builder b.WriteString("# Shared To-Do Board\n\n") b.WriteString(strconv.Itoa(open) + " open · ") b.WriteString(strconv.Itoa(done) + " done · ") b.WriteString(strconv.Itoa(open+done) + " total\n\n") if open+done == 0 { b.WriteString("_No items yet. Add one with `Add(text)`._\n") return b.String() } // Collect in ascending id order, then emit newest first. var lines []string items.Iterate("", "", func(_ string, v interface{}) bool { it := v.(*item) mark := " " if it.done { mark = "x" } line := "- [" + mark + "] #" + strconv.Itoa(it.id) + " " + it.text + " (" + shortAddr(it.author) + ")" lines = append(lines, line) return false }) for i := len(lines) - 1; i >= 0; i-- { b.WriteString(lines[i]) b.WriteString("\n") } return b.String() }
  8. #8/gno.MemPackageType
  9. #9 MPUserProd

Result log

msg:0,success:true,log:,events:[]