Transaction

66B0F3992002EE…BFDD8E46F2AD

Block 26,365 · index 0 · indexed

Summary

Hash
66B0F3992002EEB7F69F4A2129066DA60C71F0B023A4EBED1569BFDD8E46F2AD
Block
26,365
Size
5542 bytes
Gas used
9,936,894 / 11,924,332
Fee
1000000ugnot
Memo
gnopublish
Status
success

Messages

Arguments · 9

  1. #1linktree
  2. #2README.md
  3. #3# Linktree > ⚠️ **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) --- A personal links page, one profile per address. Each caller owns their own profile: they set a bio and add or remove labeled links. Anyone can browse a profile at `/<address>`, and the root page lists every profile that exists with a link to each. Profiles are stored in an ordered AVL tree so rendering is deterministic. Realm path: `gno.land/r/REPLACE_ADDR/linktree` ## Example calls ``` # set your bio SetBio("Gnome builder, coffee enthusiast") # add links AddLink("Home", "https://example.com") AddLink("GitHub", "https://github.com/me") # remove the first link (0-indexed) RemoveLink(0) ``` ## Render - `Render("")` — index of all profiles, each linking to its page. - `Render("/g1abc...")` — that address's bio + links as a Markdown bullet list. <!-- 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/linktree/v0 dependency graph](https://raw.githubusercontent.com/moul/gno-contracts/main/_assets/gno.land/r/moul/x/daily/linktree/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/linktree/v0" gno = "0.9"
  6. #6linktree.gno
  7. #7package linktree import ( "strconv" "strings" "chain" "chain/runtime/unsafe" "gno.land/p/nt/avl/v0" ) // link is a single labeled URL on a profile. type link struct { Label string URL string } // profile is one address's personal links page. type profile struct { Bio string Links []link } // profiles maps an address (string key) to its *profile. // avl.Tree keeps iteration deterministic for Render. var profiles avl.Tree // SetBio sets (or replaces) the calling address's bio. func SetBio(cur realm, bio string) { addr := unsafe.PreviousRealm().Address() p := getOrCreate(addr.String()) p.Bio = bio chain.Emit("BioSet", "addr", addr.String()) } // AddLink appends a labeled URL to the calling address's profile. func AddLink(cur realm, label string, url string) { if label == "" { panic("label must not be empty") } if url == "" { panic("url must not be empty") } addr := unsafe.PreviousRealm().Address() p := getOrCreate(addr.String()) p.Links = append(p.Links, link{Label: label, URL: url}) chain.Emit("LinkAdded", "addr", addr.String(), "label", label) } // RemoveLink deletes the link at index from the calling address's profile. func RemoveLink(cur realm, index int) { addr := unsafe.PreviousRealm().Address() key := addr.String() v := profiles.Get(key) if v == nil { panic("no profile for caller") } p := v.(*profile) if index < 0 || index >= len(p.Links) { panic("index out of range") } p.Links = append(p.Links[:index], p.Links[index+1:]...) chain.Emit("LinkRemoved", "addr", key, "index", strconv.Itoa(index)) } // getOrCreate returns the profile for key, creating an empty one if absent. func getOrCreate(key string) *profile { if v := profiles.Get(key); v != nil { return v.(*profile) } p := &profile{} profiles.Set(key, p) return p } // Render shows all profiles at root, or a single profile at "/<address>". func Render(path string) string { addr := strings.Trim(path, "/") if addr == "" { return renderIndex() } return renderProfile(addr) } func renderIndex() string { var b strings.Builder b.WriteString("# Linktree\n\n") if profiles.Size() == 0 { b.WriteString("_No profiles yet. Call `SetBio` or `AddLink` to create one._\n") return b.String() } b.WriteString("Profiles:\n\n") profiles.Iterate("", "", func(key string, _ interface{}) bool { b.WriteString("- [") b.WriteString(key) b.WriteString("](/r/REPLACE_ADDR/linktree:") b.WriteString(key) b.WriteString(")\n") return false }) return b.String() } func renderProfile(addr string) string { var b strings.Builder b.WriteString("# ") b.WriteString(addr) b.WriteString("\n\n") v := profiles.Get(addr) if v == nil { b.WriteString("_No profile for this address._\n") return b.String() } p := v.(*profile) if p.Bio != "" { b.WriteString(p.Bio) b.WriteString("\n\n") } if len(p.Links) == 0 { b.WriteString("_No links yet._\n") return b.String() } b.WriteString("## Links\n\n") for _, l := range p.Links { b.WriteString("- [") b.WriteString(l.Label) b.WriteString("](") b.WriteString(l.URL) b.WriteString(")\n") } return b.String() }
  8. #8/gno.MemPackageType
  9. #9 MPUserProd

Result log

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

← Back to block 26,365