Transaction
CA6FE08357B5DA…59B7E8168BDA
Block 26,413 · index 0 · indexed
Summary
- Hash
- CA6FE08357B5DA39649D9D9CDCE883D218F238D675334F92E84359B7E8168BDA
- Block
- 26,413
- Size
- 5267 bytes
- Gas used
- 9,670,219 / 11,604,322
- Fee
- 1000000 ugnot
- Memo
- gnopublish
- Status
- success
Messages
Arguments · 9
- #1vault
- #2README.md
- #3# Key-Value Vault > ⚠️ **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 per-address key-value store on gno.land. Each caller gets their own private namespace; only the owner can set or delete their own entries. The root render lists every address that owns a vault with its entry count, and the `/<address>` path renders that address's keys and values in a table. **Realm path:** `gno.land/r/REPLACE_ADDR/vault` ## Example calls ``` # Store a value in your namespace Set("greeting", "hello") # Overwrite it Set("greeting", "hi there") # Remove it (aborts if the key doesn't exist) Delete("greeting") ``` ## Render - `Render("")` — table of all addresses with a vault and their entry counts. - `Render("/g1abc...")` — table of that address's keys and values. <!-- 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:**  > 🧪 **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 -->
- #4gnomod.toml
- #5module = "gno.land/r/moul/x/daily/vault/v0" gno = "0.9"
- #6vault.gno
- #7package vault import ( "chain" "chain/runtime/unsafe" "strconv" "strings" "gno.land/p/nt/avl/v0" ) // vaults maps address string -> *avl.Tree (key string -> value string). var vaults avl.Tree // vaultFor returns the caller's namespace tree, creating it if needed. func vaultFor(owner address) *avl.Tree { k := owner.String() if v := vaults.Get(k); v != nil { return v.(*avl.Tree) } t := &avl.Tree{} vaults.Set(k, t) return t } // Set stores value under key in the caller's own namespace. func Set(cur realm, key string, value string) { if key == "" { panic("key must not be empty") } caller := unsafe.PreviousRealm().Address() t := vaultFor(caller) t.Set(key, value) chain.Emit("VaultSet", "owner", caller.String(), "key", key) } // Delete removes key from the caller's own namespace. func Delete(cur realm, key string) { caller := unsafe.PreviousRealm().Address() k := caller.String() v := vaults.Get(k) if v == nil { panic("no vault for caller") } t := v.(*avl.Tree) if _, removed := t.Remove(key); !removed { panic("key not found") } if t.Size() == 0 { vaults.Remove(k) } chain.Emit("VaultDelete", "owner", caller.String(), "key", key) } // Render shows all vaults (root) or a single address's entries ("/<address>"). func Render(path string) string { p := strings.TrimPrefix(path, "/") if p == "" { return renderRoot() } return renderAddress(p) } func renderRoot() string { var b strings.Builder b.WriteString("# Key-Value Vault\n\n") b.WriteString("A per-address key-value store. Each caller owns their own namespace; only the owner can mutate their entries.\n\n") if vaults.Size() == 0 { b.WriteString("_No vaults yet. Call `Set(cur, key, value)` to create one._\n") return b.String() } b.WriteString("## Vaults\n\n") b.WriteString("| Address | Entries |\n") b.WriteString("|---|---|\n") vaults.Iterate("", "", func(k string, v interface{}) bool { t := v.(*avl.Tree) b.WriteString("| [") b.WriteString(k) b.WriteString("](/r:") // link back into this realm's render for the address subpage b.WriteString(k) b.WriteString(") | ") b.WriteString(strconv.Itoa(t.Size())) b.WriteString(" |\n") return false }) b.WriteString("\nView an address's entries at path `/<address>`.\n") return b.String() } func renderAddress(addr string) string { var b strings.Builder b.WriteString("# Vault: ") b.WriteString(addr) b.WriteString("\n\n") v := vaults.Get(addr) if v == nil { b.WriteString("_No vault for this address._\n") return b.String() } t := v.(*avl.Tree) b.WriteString("| Key | Value |\n") b.WriteString("|---|---|\n") t.Iterate("", "", func(k string, val interface{}) bool { b.WriteString("| ") b.WriteString(k) b.WriteString(" | ") b.WriteString(val.(string)) b.WriteString(" |\n") return false }) b.WriteString("\nTotal entries: ") b.WriteString(strconv.Itoa(t.Size())) b.WriteString("\n") return b.String() }
- #8/gno.MemPackageType
- #9 MPUserProd
Result log
msg:0,success:true,log:,events:[]