Transaction
96EE958D90D8EE…4EEAAF35A9A8
Block 26,116 · index 0 · indexed
Summary
- Hash
- 96EE958D90D8EE0A59EBD733EE557EC0EDF950983602D30942244EEAAF35A9A8
- Block
- 26,116
- Size
- 6129 bytes
- Gas used
- 10,483,713 / 12,580,515
- Fee
- 1000000ugnot
- Memo
- gnopublish
- Status
- success
Messages
Arguments · 9
- #1stack
- #2README.md
- #3# Stack & Queue > ⚠️ **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 educational data-structure playground that maintains BOTH a LIFO **stack** and a FIFO **queue** of ints side by side. Push/Pop the stack, Enqueue/Dequeue the queue, and `Render` shows both structures with the top/front element labeled, their sizes, and a one-line reminder of how LIFO differs from FIFO. Popping or dequeuing an empty structure panics (a cross-realm abort). Realm path: `gno.land/r/REPLACE_ADDR/stack` ## Example calls ``` # Stack (LIFO) Push 1 Push 2 Push 3 Pop # -> 3 Pop # -> 2 # Queue (FIFO) Enqueue 1 Enqueue 2 Enqueue 3 Dequeue # -> 1 Dequeue # -> 2 ``` Via `gnokey`: ```sh gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/stack" -func Push -args 42 ... gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/stack" -func Pop ... gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/stack" -func Enqueue -args 42 ... gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/stack" -func Dequeue ... ``` Read the live view with `Render` (e.g. via `gnokey query vm/qrender`). <!-- 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 -->
- #4gnomod.toml
- #5module = "gno.land/r/moul/x/daily/stack/v0" gno = "0.9"
- #6stack.gno
- #7// Package stack is an educational data-structure playground that keeps BOTH a // LIFO stack and a FIFO queue of ints, so you can compare how the two behave. package stack import ( "chain" "strconv" "strings" ) // stackData holds the LIFO stack; the last pushed element is the "top". var stackData []int // queueData holds the FIFO queue; the oldest enqueued element is the "front". var queueData []int // Push adds n to the top of the LIFO stack. func Push(cur realm, n int) { stackData = append(stackData, n) chain.Emit("Push", "n", strconv.Itoa(n), "size", strconv.Itoa(len(stackData))) } // Pop removes and returns the top element of the LIFO stack. // It panics (a cross-realm abort) if the stack is empty. func Pop(cur realm) int { if len(stackData) == 0 { panic("stack is empty: nothing to pop") } last := len(stackData) - 1 n := stackData[last] stackData = stackData[:last] chain.Emit("Pop", "n", strconv.Itoa(n), "size", strconv.Itoa(len(stackData))) return n } // Enqueue adds n to the back of the FIFO queue. func Enqueue(cur realm, n int) { queueData = append(queueData, n) chain.Emit("Enqueue", "n", strconv.Itoa(n), "size", strconv.Itoa(len(queueData))) } // Dequeue removes and returns the front element of the FIFO queue. // It panics (a cross-realm abort) if the queue is empty. func Dequeue(cur realm) int { if len(queueData) == 0 { panic("queue is empty: nothing to dequeue") } n := queueData[0] queueData = queueData[1:] chain.Emit("Dequeue", "n", strconv.Itoa(n), "size", strconv.Itoa(len(queueData))) return n } // StackSize returns the number of elements in the LIFO stack. func StackSize() int { return len(stackData) } // QueueSize returns the number of elements in the FIFO queue. func QueueSize() int { return len(queueData) } // renderInts formats a slice of ints as a space-separated list, e.g. "1 2 3". func renderInts(xs []int) string { if len(xs) == 0 { return "_(empty)_" } parts := make([]string, len(xs)) for i, x := range xs { parts[i] = strconv.Itoa(x) } return "`" + strings.Join(parts, " ") + "`" } // Render returns a Markdown view of both structures with top/front labeled, // their sizes, and a one-line explanation of LIFO vs FIFO. func Render(path string) string { var b strings.Builder b.WriteString("# Stack & Queue Playground\n\n") b.WriteString("A **stack** is LIFO (last in, first out) — the last item pushed is the first popped. ") b.WriteString("A **queue** is FIFO (first in, first out) — the first item enqueued is the first dequeued.\n\n") b.WriteString("## Stack (LIFO) — size ") b.WriteString(strconv.Itoa(len(stackData))) b.WriteString("\n\n") b.WriteString("Contents (bottom → top): ") b.WriteString(renderInts(stackData)) b.WriteString("\n\n") if len(stackData) > 0 { b.WriteString("Top: `") b.WriteString(strconv.Itoa(stackData[len(stackData)-1])) b.WriteString("` — the next `Pop` returns this.\n\n") } else { b.WriteString("Top: _(none)_ — `Pop` would panic.\n\n") } b.WriteString("## Queue (FIFO) — size ") b.WriteString(strconv.Itoa(len(queueData))) b.WriteString("\n\n") b.WriteString("Contents (front → back): ") b.WriteString(renderInts(queueData)) b.WriteString("\n\n") if len(queueData) > 0 { b.WriteString("Front: `") b.WriteString(strconv.Itoa(queueData[0])) b.WriteString("` — the next `Dequeue` returns this.\n\n") } else { b.WriteString("Front: _(none)_ — `Dequeue` would panic.\n\n") } b.WriteString("---\n\n") b.WriteString("_Tip: push the same sequence into both, then Pop vs Dequeue to see LIFO reverse it while FIFO preserves order._\n") return b.String() }
- #8/gno.MemPackageType
- #9 MPUserProd
Result log
msg:0,success:true,log:,events:[]