Agent API endpoints

Mystery links

Make, claim, open and take back mystery links.

For code that signs with its own wallet (Agent API): the endpoints that make, claim, open and take back mystery links. A mystery link is one pool of tokenized stocks and tokens behind one link, split into prizes of different sizes. Every wallet that claims gets one box and its prize is drawn as it opens. Mystery links live on Base. The fee is 2.5% on top plus a draw fee, both named in summary.fee. Every path here is under https://www.giftedstock.com/api/agent/v1 and every write answers with a plan, as described in Requests, plans and errors. For what a mystery link is to the people who claim one, see Create a mystery link.

Open and the draw

POST /tx/mystery/open

POST https://www.giftedstock.com/api/agent/v1/tx/mystery/open
{ "wallet": "0xYou", "skill": "1.7.0", "ids": ["57"] }

ids: 1 to 50 boxes this wallet claimed and has not opened. A claim already opens its box, so this is for a box claimed without it. A claimed box can be opened until 30 days after its link's end date, unless the link was taken back.

  • Each open takes a drand round published a few seconds after it, so nobody can know the prize when the box is opened.
  • Our drawer checks drand's signature for that round onchain, draws the prize from the ones left and sends it to the wallet that holds the box, paid by the draw fee. There is nothing more to send.
  • Read the prize with GET https://www.giftedstock.com/api/agent/v1/mystery/<poolId>?claimer=0xYou. A mystery box stays in the wallet that claimed it and can't be sent on.
  • How the draw works and how to replay it: Odds and randomness.

Take back what is left

POST /tx/mystery/take-back

POST https://www.giftedstock.com/api/agent/v1/tx/mystery/take-back
{ "wallet": "0xYou", "skill": "1.7.0", "poolId": 12 }
  • Only the link's maker, from its end date or once every box is claimed.
  • It sends back all but the biggest prizes left, one for each claimed box not drawn yet, so whatever those boxes draw is still there. summary.back is what comes back now and summary.staysUsd what stays. Call it again later for what came free since; once no box can draw any more it sends the rest and the link is done (summary.closes).
  • A box still sealed 30 days after the end date can no longer be opened: its prize comes free too.
  • Tokenized stocks and tokens come back to your wallet, not the USDC or ETH you paid with. The fees are not returned.

Refusals

CodeStatusFromMeaning
not_live404every mystery routeMystery links are not on this site right now.
unknown_field400every planA field the endpoint doesn't take (a link field too): the message names it.
bad_items, bad_token, unknown_token, bad_amount, below_minimum400makeAn item is missing, twice, not a token a mystery link takes or not dollars of at least $0.01.
bad_prizes400makeNot ladder, jackpot or a list of up to 16 { usd, count } that adds up to the items' dollars and link.boxes, or too many boxes for the pool.
prize_too_small400makeThe smallest prize holds less than a box's minimum of a token: raise the pool or pick fewer boxes.
bad_pay, bad_note, bad_design400makeThat field breaks its rule above (a sticker the chain does not draw yet is bad_design).
bad_who, bad_list, bad_time400makeA link field breaks its rule, closesAt is null or 0 or claims close before they open.
bad_link_key, link_key_used400makeThe link key is your wallet's, used on Base or another link's key: make a fresh one.
token_not_allowed, not_buyable, no_price400 or 409makeA token can't go in a mystery link or be bought right now.
token_paused, pool_not_listed409makeThat stock is paused or its pool can't be bought through right now: try again later.
price_moved, fee_changed, draw_fee_changed409makePrices, the fee or the draw fee moved: build the plan again.
paused, verified_off409make, claimNew mystery links are paused or verified-only links are off right now.
insufficient_balance409makeThe wallet holds less USDC or ETH than the plan takes at most.
rate_limited429makeToo many wallet lists or new notes in a day: wait as long as the message says.
no_mystery_link404claim, take back, readNo mystery link with that poolId.
none_left, not_open_yet, claims_closed, already_claimed409claimNothing to claim for this wallet right now.
not_verified, not_on_list403claimThis link is for verified wallets or a list.
list_unknown, not_claimable_here, claim_refused409 or 4xxclaimThis link's gate is not one this site serves or its check refused this claim: the message says why.
approval_expired, bad_approval409claimA verified-only link's approval ran out or did not hold: ask for the claim again.
bad_signature, bad_link_signature400claimNot 65 bytes or not the link key's signature over this typed data (a link given a new key has a new one).
try_again409claim, opendrand's next round is already out by Base's clock: build the plan again in a few seconds.
bad_ids, no_box400 or 404openids is not 1 to 50 box ids or a box does not exist.
not_holder403openThe box is not in this wallet.
not_sealed, open_closed409openThe box is opened already, its link was taken back or it ended more than 30 days ago.
not_creator403take backOnly the link's maker takes back.
still_open, nothing_free, none_left, taken_back409take backClaims are still open, nothing has come free yet, every box is claimed and drawn or everything left was taken back.
bad_number400readpoolId is not a whole number from 1.
would_revert409every planThe mystery link contract would refuse it, named where it can be.

The codes every endpoint shares are on Requests, plans and errors.