sponsor_swap
Settles shielded token swaps by merging two mirrored offer halves, with a sponsor paying the fee, then submits the transaction and waits for settlement and receipt.
Instructions
A swap settles two shielded tokens between two wallets without a contract: each side builds one half (it spends the coin it gives and creates the coin it wants), the two mirrored halves merge into one transaction, and a sponsor pays the fee. This hands the two halves to the sponsor, which checks them, merges them, pays the dust and submits: each half carries an offer and nothing else, gives exactly one token type and wants exactly one other, both on the sponsor's token allow-list and never NIGHT, at most 4 inputs and 2 outputs per half, and the halves mirror each other in types and amounts. A half may be bound or unbound and is passed as offer file text or base64. Off on a server by default (NIGHTGATE_SPONSOR_ALLOW_SWAPS); an agent grant needs sponsorSwap in its allowedActions. Job result { txHash, transactionHash, swap: { gives, wants } }. An offer fills once: if it was taken first by somebody else the job fails. Pass both halves, or halfId alone for an offer this server took (take_swap_offer keeps both halves); with offerId the maker half comes from the board, next to takerHalf or the halfId of the taken offer. The tool also waits for the block (about a minute more) and then carries the instance's signed receipt; if that wait runs out, receipt is null and the same call again fetches it. The tool waits until the job settled (about 1 minute) and returns { status, txHash, transactionHash, result }. failed: next says what to do. If the call was cut off or came back pending, run it again with the same arguments: it picks up the job it started and submits nothing new (the answer says deduplicated). A second, separate call with the same arguments needs a new idempotencyKey.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| halfId | No | Id of the half this server built for the swap: alone it names a taken offer, next to both halves it ties the job to the half | |
| offerId | No | An offer on the server's board (list_swap_offers): the server takes the maker half from there; pass takerHalf or the halfId of the taken offer with it | |
| makerHalf | No | The maker's half (the offer): offer file text (swapoffer1...) or base64 of the serialized, proven transaction | |
| takerHalf | No | The taker's half: offer file text (swapoffer1...) or base64 of the serialized, proven transaction | |
| takerSecret | No | For a directed board offer: the secret its poster handed you | |
| idempotencyKey | No | Dedupes retries of the SAME two halves |