Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v1 source realm

nsmarket — names for sale, without anybody holding anything.

Overview

nsmarket — names for sale, without anybody holding anything.

HOW A SALE WORKS, and why it is built this way.

The seller keeps their name. Listing does not move it here: it records an asking price and relies on the GRC-721 approval the seller has already granted this realm. Ownership does not change until somebody buys, and the seller can walk away at any moment by revoking the approval — at which point the listing simply stops working.

The buyer's money is never held either. Buy is ONE call: it checks the listing still stands, moves the name, pays the seller, takes the fee, refunds any overpayment. All of it inside the transaction the buyer signed. If any part fails the whole thing reverts and nothing moved.

Which means: at no point does this realm hold somebody else's name or somebody else's money. That is not a nice-to-have. An escrow that holds either one is a different kind of business, with a different set of rules, run by people with licences.

THIS REALM HAS NO VAULT PRIVILEGES. It is not in nsdata's trusted set and does not ask to be. Every transfer goes through nslogic's ordinary GRC-721 path, which means it can only move a name the owner has explicitly approved — the same permission any other marketplace would need. However wrong the code below turns out to be, the worst it can do is fail.

Functions 13

func Buy

crossing Action
1func Buy(cur realm, tid string)
source

Buy completes a sale in the buyer's own transaction.

Order matters here. Everything that can refuse the sale is checked before a single coin moves, and the name moves before the money does, so there is no arrangement of failures that leaves the seller paid and the buyer empty-handed. A panic anywhere reverts all of it.

func FeeFor

Action
1func FeeFor(price int64) (fee, toSeller int64)
source

FeeFor is what the house takes on a sale at this price, and what the seller is left with. Exported so the listing screen can show both before anybody signs — a fee somebody discovers afterwards is a fee they were not told about.

func GetListing

Action
1func GetListing(tid string) string
source

GetListing returns one row, or "" when nothing is listed.

func List

crossing Action
1func List(cur realm, tid string, price int64)
source

List puts a name up for sale at a price in ugnot.

It does NOT take the name. The seller keeps it, keeps using it, and keeps the right to change their mind — revoking the approval kills the listing without needing this realm's cooperation at all.

The approval is required BEFORE listing rather than checked only at sale time, so a listing that could never complete cannot exist. A buyer finding out at the checkout that the seller never approved anything is the worst moment to find out.

func ListForSale

Action
1func ListForSale(after string, limit int) (rows, next string)
source

ListForSale pages through everything on offer, cheapest first within a page. `after` is the last token id of the previous page.

func ListingsBy

Action
1func ListingsBy(seller address) string
source

ListingsBy is everything one wallet has up for sale. Walks the whole tree because listings are keyed by token id, not by seller: a second index would be a second thing to keep correct and a second thing the seller pays storage for, to save a walk over a list that is small by construction.

func Quote

Action
1func Quote(tid string) (price, fee, toSeller int64)
source

Quote is what a buyer pays and what the seller receives, before anybody signs anything. The fee is read live, so this is the same arithmetic Buy will do rather than a copy of it that can drift.

func SetFee

crossing Action
1func SetFee(cur realm, spec string)
source

SetFee changes it. Admin only, and validated here rather than trusted, because a malformed spec would otherwise be read on every sale and silently resolve to zero.

func Unlist

crossing Action
1func Unlist(cur realm, tid string)
source

Unlist withdraws a listing. The seller, or the admin for a name that should not be on sale at all — the same manual lever the takedown process already relies on elsewhere.

func Version

Action
1func Version() string
source

Version lets the site tell which shape it is talking to without guessing from a function signature.

Types 1

type Listing

struct
1type Listing struct {
2	seller address
3	price  int64 // ugnot
4	listed int64 // unix seconds
5}
source

A listing. Kept small on purpose: the seller pays to store it, and everything derivable is derived rather than copied. The seller's address is here because the name can change hands outside this realm and a stale seller must be caught, not trusted.

Imports 11

Source Files 5