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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

gnocial source realm

Package gnocial is a SocialFi realm: profiles, posts, follows, GNOT tips, and creator tickets priced on a quadratic b...

Overview

Package gnocial is a SocialFi realm: profiles, posts, follows, GNOT tips, and creator tickets priced on a quadratic bonding curve.

Each ticket trade charges FeeCapBps of the curve. The creator chooses a share from CreatorFeeMinBps to CreatorFeeMaxBps. A creator referrer and a trader referrer each take a fixed slice when that person exists. The treasury receives the rest of the cap. That remainder is this package's schedule. Arena has not published its protocol percent.

Ticket collateral sits in this realm as totalReserve. Trade fees are forwarded out of that collateral, and Sweep only sends coins above it. This package does not receive the reserve of an earlier realm.

Constants 1

const FeeCapBps, CreatorFeeMinBps, CreatorFeeMaxBps, CreatorFeeDefaultBps, CreatorReferralBps, TraderReferralBps, TicketUnit, MaxSupply, MaxTrade, MaxBodyRunes, ProtocolVersion, maxHandle, minHandle, maxNameRunes, maxNameBytes, maxBioRunes, maxBioBytes, maxBodyBytes

 1const (
 2	// FeeCapBps is the total taken from the curve on every buy and every sell.
 3	FeeCapBps int64 = 1_000
 4	// CreatorFeeMinBps is the smallest share a creator may keep.
 5	CreatorFeeMinBps int64 = 100
 6	// CreatorFeeMaxBps is the largest share a creator may keep.
 7	CreatorFeeMaxBps int64 = 700
 8	// CreatorFeeDefaultBps is stored on a profile at Register.
 9	CreatorFeeDefaultBps int64 = 500
10	// CreatorReferralBps is paid to the creator's referrer when they have one.
11	CreatorReferralBps int64 = 50
12	// TraderReferralBps is paid to the buyer or seller's referrer when they have one.
13	TraderReferralBps int64 = 50
14	// TicketUnit is the ugnot price of ticket number 1. Ticket i costs i² units.
15	TicketUnit int64 = 10_000
16	// MaxSupply is the most tickets one creator can have outstanding.
17	MaxSupply = 2000
18	// MaxTrade is the most tickets one buy or sell can move.
19	MaxTrade = 20
20	// MaxBodyRunes is the longest post, counted in runes.
21	MaxBodyRunes = 280
22	// ProtocolVersion is the immutable revision of this package.
23	// A later package is announced with SetSuccessor. It does not hold this reserve.
24	ProtocolVersion = "2"
25
26	maxHandle    = 16
27	minHandle    = 3
28	maxNameRunes = 32
29	maxNameBytes = 128
30	maxBioRunes  = 160
31	maxBioBytes  = 640
32	maxBodyBytes = 1120
33)
source

Functions 46

func Buy

crossing Action
1func Buy(cur realm, handle string, amount int)
source

Buy mints amount tickets of handle. Attach exactly QuoteBuy's due in ugnot. The caller's own referrer receives the trader slice. The due matches QuoteBuy.

func Delete

crossing Action
1func Delete(cur realm, id int)
source

Delete soft-deletes the caller's post and clears its body from current state. The original transaction still holds the text in chain history.

func FeedCount

Action
1func FeedCount() int
source

FeedCount is the number of live top-level posts still in the feed index.

func Follow

crossing Action
1func Follow(cur realm, handle string)
source

Follow records that the caller follows handle.

func Following

Action
1func Following(from address, handle string) bool
source

Following reports whether from follows the handle.

func GatedBody

crossing Action
1func GatedBody(cur realm, id int) string
source

GatedBody returns a gated post's text for the author or a current ticket holder. Chain storage is public; this only gates the convenience call and Render.

func LatestID

Action
1func LatestID() int
source

LatestID is the newest post id, or 0 when nothing has been posted.

func Like

crossing Action
1func Like(cur realm, id int)
source

Like adds the caller's like. One like per account.

func Liked

Action
1func Liked(who address, id int) bool
source

Liked reports whether who liked the post.

func Paused

Action
1func Paused() bool
source

Paused reports whether new posts, replies, tips, and ticket buys are frozen. Sells stay open so ticket collateral can still exit.

func Post

crossing Action
1func Post(cur realm, body, gated string) int
source

Post publishes a top-level post and returns its id. gated is yes/1/true/khoa to withhold the body from Render. The body is still public chain state. Pass an empty gated value for a public post.

func QuoteBuy

Action
1func QuoteBuy(handle string, amount int) (due, curve, creatorFee, protocolFee, referralFee int64)
source

QuoteBuy is the exact ugnot a buyer must attach to mint amount tickets. The total fee is always FeeCapBps of the curve. An anonymous quote pays no trader-referrer slice, so that slice stays in the protocol fee. The amount due does not change when the buyer is known.

func QuoteBuyFor

Action
1func QuoteBuyFor(handle, buyer string, amount int) (due, curve, creatorFee, protocolFee, referralFee int64)
source

QuoteBuyFor is QuoteBuy with the buyer's address. Empty or a member with no referrer adds no trader-referrer slice. A bad address panics.

func QuoteSell

Action
1func QuoteSell(handle string, amount int) (proceeds, curve, creatorFee, protocolFee, referralFee int64)
source

QuoteSell is what a seller receives. The reserve drops by the full curve. Proceeds are the curve minus FeeCapBps, whoever the seller is.

func QuoteSellFor

Action
1func QuoteSellFor(handle, seller string, amount int) (proceeds, curve, creatorFee, protocolFee, referralFee int64)
source

QuoteSellFor is QuoteSell with the seller's address.

func Register

crossing Action
1func Register(cur realm, handle, name, bio, referrer string)
source

Register opens a profile for the calling account. handle is 3–16 chars of a-z, 0-9 and underscore. referrer may be empty or the bech32 address of an existing member. A member can register once.

func Render

1func Render(path string) string
source

Render is the short gnoweb page for this fund realm. The long client and Sheet live in the view realm. A realm has to declare Render, and the storage deposit of this package cannot hold both the curve and the full client.

func Reply

crossing Action
1func Reply(cur realm, parent int, body string) int
source

Reply publishes a reply to parent and returns the new id. Replies are public.

func Sell

crossing Action
1func Sell(cur realm, handle string, amount int)
source

Sell burns amount tickets and pays the caller from the reserve, minus fees. Sells stay available while the realm is paused.

func SetCreatorFee

crossing Action
1func SetCreatorFee(cur realm, points int64)
source

SetCreatorFee stores this member's share of each ticket trade, in basis points. Only that member can change it. The trade total stays FeeCapBps.

func SetPaused

crossing Action
1func SetPaused(cur realm, on string)
source

SetPaused freezes posts, replies, tips, and ticket buys when on is true/1/yes. Pass false/0/no to reopen. Ticket sells are never paused.

func SetSuccessor

crossing Action
1func SetSuccessor(cur realm, next string)
source

SetSuccessor records the package path of a later realm. An empty path clears it. This does not move coins or shares.

func SetTreasury

crossing Action
1func SetTreasury(cur realm, next address)
source

SetTreasury moves future protocol fees and surplus sweeps to next.

func SharesOf

Action
1func SharesOf(holder address, handle string) int
source

SharesOf returns how many tickets holder has of the creator's handle.

func Successor

Action
1func Successor() string
source

Successor is the package path of a later realm, or empty. The later realm does not receive this realm's ticket reserve.

func SupplyOf

Action
1func SupplyOf(handle string) (supply int, reserve int64, holders int)
source

SupplyOf returns tickets outstanding, ugnot locked in that curve, and holders.

func Sweep

crossing Action
1func Sweep(cur realm, confirm string)
source

Sweep sends this realm's ugnot above TotalReserve to the treasury. confirm must be the word "sweep". Ticket collateral is not included.

func Tip

crossing Action
1func Tip(cur realm, id int)
source

Tip forwards the attached ugnot to the post's author. The realm does not keep it.

func Unlike

crossing Action
1func Unlike(cur realm, id int)
source

Unlike removes the caller's like.

func UpdateProfile

crossing Action
1func UpdateProfile(cur realm, name, bio string)
source

UpdateProfile replaces the display name and bio. The handle stays.

func Feed

Action
1func Feed(before, limit int) []Article
source

Feed lists newest top-level posts with id < before. before 0 starts at the newest.

func GetPost

Action
1func GetPost(id int) (Article, bool)
source

GetPost returns a copy of the post. The copy does not alias storage.

func Hot

Action
1func Hot(limit int) []Article
source

Hot ranks the newest window the same way Render does. It is not a global index.

func PostsBy

Action
1func PostsBy(addr address, before, limit int) []Article
source

PostsBy lists one member's newest top-level posts with id < before.

func Replies

Action
1func Replies(parent, after, limit int) []Article
source

Replies lists direct replies of parent with id > after, oldest first.

func Holdings

Action
1func Holdings(holder, after address, limit int) []Holding
source

Holdings lists ticket balances of holder, after the given creator address.

func FollowerList

Action
1func FollowerList(who, after address, limit int) []Profile
source

FollowerList lists profiles that follow `who`, in address order, after `after`.

func FollowingList

Action
1func FollowingList(who, after address, limit int) []Profile
source

FollowingList lists profiles `who` follows, in address order, after `after`.

func Handles

Action
1func Handles(after string, limit int) []Profile
source

Handles lists profiles in handle order, strictly after the given handle.

func ProfileByHandle

Action
1func ProfileByHandle(handle string) (Profile, bool)
source

ProfileByHandle returns a copy of the profile, or false when the handle is unknown.

func ProfileOf

Action
1func ProfileOf(addr address) (Profile, bool)
source

ProfileOf returns a copy of the profile bound to addr.

Types 3

type Article

struct
 1type Article struct {
 2	ID      int
 3	Author  address
 4	Body    string
 5	Height  int64
 6	ReplyTo int
 7	Likes   int
 8	Replies int
 9	Tips    int64
10	Gated   bool
11	Deleted bool
12}
source

Article is a copy of one post. Gated bodies are still stored on chain; Render withholds them, and GatedBody checks the caller.

type Holding

struct
1type Holding struct {
2	Creator address
3	Handle  string
4	Amount  int
5}
source

Holding is one creator's tickets in a wallet. It is a copy.

type Profile

struct
 1type Profile struct {
 2	Addr       address
 3	Handle     string
 4	Name       string
 5	Bio        string
 6	Referrer   address
 7	Joined     int64
 8	Posts      int
 9	Followers  int
10	Following  int
11	TipsIn     int64
12	TipsOut    int64
13	CreatorFee int64
14}
source

Profile is a copy of a member's public record.

Dependencies

Source Files 10