Transaction

4C944E3B580450…EE0F370AB779

Block 26,361 · index 0 · indexed

Summary

Hash
4C944E3B580450AE3443DCCF72568B5D1E6BF117DB63B8D02FFAEE0F370AB779
Block
26,361
Size
4972 bytes
Gas used
9,403,854 / 11,284,684
Fee
1000000ugnot
Memo
gnopublish
Status
success

Messages

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

Arguments · 9

  1. #1kudos
  2. #2README.md
  3. #3# Kudos > ⚠️ **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) --- Give props to other addresses on-chain. Anyone can call `Give` to credit another address with a kudos and a short reason; you cannot kudos yourself. The realm keeps a running leaderboard of the most-appreciated addresses and a rolling feed of the most recent kudos. Realm path: `gno.land/r/REPLACE_ADDR/kudos` ## Example calls ``` # Give a kudos to another address Give(to="g1...bob", reason="great code review") # View the leaderboard + recent feed (read-only) Render("") ``` `Render` returns Markdown: a ranked leaderboard table (address, kudos count) followed by a recent-kudos feed (`from → to: reason`). <!-- 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/kudos/v0 dependency graph](https://raw.githubusercontent.com/moul/gno-contracts/main/_assets/gno.land/r/moul/x/daily/kudos/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/kudos/v0" gno = "0.9"
  6. #6kudos.gno
  7. #7package kudos import ( "chain" "chain/runtime/unsafe" "sort" "strconv" "strings" "gno.land/p/nt/avl/v0" ) // counts maps an address (as string) -> number of kudos received. var counts avl.Tree // feed holds recent kudos, newest first, capped at feedCap entries. var feed []kudo const feedCap = 50 type kudo struct { from address to address reason string } // Give records a kudos from the caller to `to` with a reason. // A caller cannot give kudos to themselves. func Give(cur realm, to address, reason string) { from := unsafe.PreviousRealm().Address() if !to.IsValid() { panic("invalid recipient address") } if from == to { panic("cannot give kudos to yourself") } reason = strings.TrimSpace(reason) if reason == "" { panic("reason must not be empty") } key := to.String() n := int64(0) if v := counts.Get(key); v != nil { n = v.(int64) } counts.Set(key, n+1) // prepend newest, cap the feed feed = append([]kudo{{from: from, to: to, reason: reason}}, feed...) if len(feed) > feedCap { feed = feed[:feedCap] } chain.Emit("KudosGiven", "from", from.String(), "to", to.String(), "reason", reason) } // entry is a leaderboard row used for deterministic sorting. type entry struct { addr string count int64 } // byScore sorts by count desc, then address asc for stable ties. type byScore []entry func (s byScore) Len() int { return len(s) } func (s byScore) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s byScore) Less(i, j int) bool { if s[i].count != s[j].count { return s[i].count > s[j].count } return s[i].addr < s[j].addr } func leaderboard() []entry { out := make([]entry, 0, counts.Size()) counts.Iterate("", "", func(key string, value any) bool { out = append(out, entry{addr: key, count: value.(int64)}) return false }) sort.Sort(byScore(out)) return out } // Render shows a leaderboard of most-received addresses and a recent feed. func Render(path string) string { var b strings.Builder b.WriteString("# Kudos\n\n") b.WriteString("Give props to addresses. `Give(to, reason)` records a kudos.\n\n") b.WriteString("## Leaderboard\n\n") lb := leaderboard() if len(lb) == 0 { b.WriteString("_No kudos yet._\n\n") } else { b.WriteString("| # | Address | Kudos |\n") b.WriteString("| --- | --- | --- |\n") for i, e := range lb { b.WriteString("| " + strconv.Itoa(i+1) + " | " + e.addr + " | " + strconv.FormatInt(e.count, 10) + " |\n") } b.WriteString("\n") } b.WriteString("## Recent kudos\n\n") if len(feed) == 0 { b.WriteString("_Nothing here yet._\n") } else { for _, k := range feed { b.WriteString("- " + k.from.String() + " → " + k.to.String() + ": " + k.reason + "\n") } } return b.String() }
  8. #8/gno.MemPackageType
  9. #9 MPUserProd

Result log

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

← Back to block 26,361