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

agent_registry_v2 source realm

Constants 1

const MaxAgents, MaxNameLen, MaxDescLen, MaxCapsLen, MaxReviewLen, ReviewRenderMax, AdminAddress, MaxAgentsPerCreator, MaxDepositorsPerAgent

 1const (
 2	MaxAgents    = 100
 3	MaxNameLen   = 100
 4	MaxDescLen   = 1000
 5	MaxCapsLen   = 2000
 6	MaxReviewLen = 500
 7	// AR-1 render-DoS bound: reviews are sybil-growable (one per address, no cap), and
 8	// renderAgent previously iterated the entire slice — an attacker could make an agent
 9	// page unrenderable past the query gas cap. Render only the newest window.
10	ReviewRenderMax = 20
11	AdminAddress    = "g1x7k4628w93a7wzdhqc06atzx0v50rnshweuxu0" // samcrew-core-test1 multisig
12
13	// AAA-1 B4 — anti-squat + fund-lock-DoS bounds.
14	// MaxAgentsPerCreator caps how many agents one address can register, so a
15	// single funded address cannot squat the whole MaxAgents global supply.
16	MaxAgentsPerCreator = 10
17	// MaxDepositorsPerAgent bounds the distinct depositor set per agent. RemoveAgent
18	// refunds EVERY depositor in one transaction (the credits prefix scan below); an
19	// unbounded set would make RemoveAgent exceed the block gas budget and become
20	// permanently uncallable, locking all deposited funds. At this cap the full
21	// refund loop measures ≈3M gas in `gno test` — a small fraction of the block
22	// budget, so RemoveAgent stays callable with wide headroom.
23	MaxDepositorsPerAgent = 50
24)
source

Functions 15

func DepositCredits

crossing Action
1func DepositCredits(cur realm, agentId string)
source

DepositCredits deposits GNOT as prepaid credits for an agent. Send ugnot with the transaction to fund the credits.

func GetCredits

Action
1func GetCredits(agentId, userAddr string) int64
source

GetCredits returns the credit balance for a user on an agent.

func GetEarnings

Action
1func GetEarnings(agentId string) int64
source

GetEarnings returns accumulated earnings for an agent.

func GetUsage

Action
1func GetUsage(agentId, userAddr string) int64
source

GetUsage returns the total invocation count for a user on an agent.

func Pause

crossing Action
1func Pause(cur realm)
source

Pause blocks all state-mutating operations EXCEPT RefundCredits (users keep the right to reclaim their own deposits). Admin only. See the pause policy above.

func RefundCredits

crossing Action
1func RefundCredits(cur realm, agentId string)
source

RefundCredits refunds remaining credits to the caller.

func RegisterAgent

crossing Action
1func RegisterAgent(
2	cur realm,
3	id, name, description, category, capabilities,
4	endpoint, transport, pricing, version string,
5	pricePerCall int64,
6)
source

RegisterAgent registers a new agent in the registry.

func RemoveAgent

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

RemoveAgent removes an agent (admin or creator only). All outstanding credits are refunded to their depositors before removal.

func ReviewAgent

crossing Action
1func ReviewAgent(cur realm, agentId string, rating int, comment string)
source

ReviewAgent adds a review for an agent. One review per address per agent.

func Unpause

crossing Action
1func Unpause(cur realm)
source

Unpause resumes normal operations. Admin only.

func UpdateAgent

crossing Action
1func UpdateAgent(
2	cur realm,
3	id, description, capabilities, endpoint, version, pricing string,
4	pricePerCall int64,
5)
source

UpdateAgent allows the creator to update their agent.

func UseCredit

crossing Action
1func UseCredit(cur realm, agentId, userAddr string) int64
source

UseCredit deducts one invocation credit. Only the agent creator or admin can call. Returns the remaining credits.

func WithdrawEarnings

crossing Action
1func WithdrawEarnings(cur realm, agentId string)
source

WithdrawEarnings allows the agent creator to withdraw accumulated usage fees. Earnings accumulate when UseCredit deducts from user credit balances.

Types 2

type Agent

struct
 1type Agent struct {
 2	ID           string
 3	Name         string
 4	Description  string
 5	Category     string
 6	Capabilities string // comma-separated
 7	Creator      address
 8	Endpoint     string
 9	Transport    string // "stdio" | "sse" | "streamable-http"
10	Pricing      string // "free" | "pay-per-use" | "subscription"
11	PricePerCall int64  // in ugnot (0 if free)
12	Version      string
13	TotalCalls   int64
14	RatingSum    int64
15	RatingCount  int64
16	BlockH       int64
17}
source

type Review

struct
1type Review struct {
2	Reviewer address
3	Rating   int // 1-5
4	Comment  string
5	BlockH   int64
6}
source

Imports 8

Source Files 2