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.

ads2 source realm

Functions 23

func ApproveTask

crossing Action
1func ApproveTask(cur realm, taskId string, claimerAddr string)
source

ApproveTask marks a task claim as approved. Only the task's advertiser or the admin may approve. Coin reward is handled server-side via the minter.

func ClaimRefEarnings

crossing Action
1func ClaimRefEarnings(cur realm)
source

ClaimRefEarnings moves the caller's accumulated referral earnings into a pending payout queue. The treasury server reads RefPendingClaim(), sends GNOT from the treasury wallet, then calls ClearRefClaim() to zero it.

func ClearRefClaim

crossing Action
1func ClearRefClaim(cur realm, referrerAddr string)
source

ClearRefClaim is called by the admin/treasury after disbursing GNOT to a referrer. Zeroes the pending payout entry.

func DepositBid

crossing Action
1func DepositBid(cur realm, ugnotAmount string)
source

DepositBid credits the caller's advertiser balance with the declared ugnot amount. The caller must attach matching coins to the MsgCall (the VM holds them in the realm's address). The amount is passed explicitly so the realm can credit it without importing chain/banker.

Security: the treasury server MUST verify the on-chain balance before approving any campaign spend — it should call AdvertiserBalance() to cross-check the declared amount matches what was actually deposited.

func GetCampaign

Action
1func GetCampaign(campaignId string) string
source

GetCampaign returns the JSON string for a single campaign, or "null".

func GetTask

Action
1func GetTask(taskId string) string
source

GetTask returns the JSON for a single task, or "null".

func GetTaskClaim

Action
1func GetTaskClaim(taskId string, claimerAddr string) string
source

GetTaskClaim returns the claim status string for a taskId+claimerAddr pair.

func ListCampaigns

Action
1func ListCampaigns(advertiserAddr string) string
source

ListCampaigns returns a JSON array of campaigns submitted by advertiserAddr.

func ListTasks

Action
1func ListTasks(advertiserAddr string) string
source

ListTasks returns a JSON array of tasks submitted by advertiserAddr.

func RecordView

crossing Action
1func RecordView(cur realm, campaignId string)
source

RecordView bills the advertiser one bid_per_view for a player watching an ad. Deduplicated per (campaignId, callerAddr, UTC day). Splits 50% of the bid to the referrer if one is registered for the advertiser.

func RefEarnings

Action
1func RefEarnings(addr string) string
source

RefEarnings returns the claimable referral earnings for an address.

func RefPendingClaim

Action
1func RefPendingClaim(addr string) string
source

RefPendingClaim returns the pending payout amount for a referrer address. The treasury server calls this before sending GNOT.

func RegisterReferral

crossing Action
1func RegisterReferral(cur realm, referrerAddr string)
source

RegisterReferral permanently links the calling advertiser to a referrer. Each advertiser may register exactly one referrer; cannot be changed.

func ReviewCampaign

crossing Action
1func ReviewCampaign(cur realm, campaignId string, decision string)
source

ReviewCampaign approves or rejects a campaign. Approved campaigns transition to "active" and can receive views.

func SelectAd

Action
1func SelectAd(viewerLevel int) string
source

SelectAd returns the JSON of the winning campaign for the given viewer level, chosen by weighted auction (higher bid_per_view = proportionally more weight). Returns "null" if no eligible campaign exists.

NOTE: uses time.Now().UnixNano() % totalWeight as deterministic pseudo-random. Not cryptographic — sufficient for ad placement.

func SubmitCampaign

crossing Action
1func SubmitCampaign(cur realm, campaignJson string) string
source

SubmitCampaign stores a campaign JSON and queues it for admin review. Returns the generated campaignId. Status is forced to "pending_review" regardless of what the client sends.

func SubmitTask

crossing Action
1func SubmitTask(cur realm, taskId string, proofUrl string)
source

SubmitTask records a player's proof-of-completion claim on a paid task.

func SubmitTaskDef

crossing Action
1func SubmitTaskDef(cur realm, taskJson string) string
source

SubmitTaskDef creates a new paid social task. Returns the taskId.

func TotalViews

Action
1func TotalViews(campaignId string) string
source

TotalViews returns the total recorded view count for a campaign.

Dependencies

Source Files 2