near sponsor: create and relay for the blackbeard wallet's NEAR accounts #51

Open
opened 2026-10-09 10:33:35 +00:00 by grenade · 0 comments
Owner

The observer's side of blackbeard/wallet#81. Read that issue for the decisions. In short: blackbeard-observer.near creates each wallet's NEAR account, then relays its legs as NEP-366 meta-transactions and pays the gas. A swap fee (wallet#82) pays for it. Nothing the relayer refuses reaches NEAR.

Endpoints

  • GET /v1/near/sponsor: the terms. Sponsor account, fee in bps and its recipient, the relay rules, and whether the sponsor is enabled.
  • POST /v1/near/accounts { public_key: "ml-dsa-65:<base58>" }: creates b<…>.blackbeard-observer.near for that key, in one transaction: CreateAccount, Transfer of NEAR's storage minimum, AddKey. If it already exists with that key, it is returned. Idempotent by construction: the name is a function of the key.
  • POST /v1/near/relay { signed_delegate: base64 }: decoded and verified with wallet-near, checked against the rules, wrapped in a transaction from the sponsor and submitted. Returns the transaction hash.

Rules (in blackbeard-core, no I/O, unit-tested with delegate actions built by wallet-near):

  • sender: the sponsored name of the delegate's own key;
  • receiver: intents.near or wrap.near;
  • actions: function calls only, from a fixed list of methods, gas capped per method, deposits limited to what those methods need;
  • fee: a pool-swap ft_withdraw to dclv2.ref-labs.near must come with the fee's mt_transfer in the same delegate action. The fee is in the input token, at least ceil(amount × bps / 10000), to the fee recipient.

Limits: per sender, per client address, and a daily cap on relayed transactions.

Shape:

  • Code: wallet-near comes from the wallet repo by git rev, so the sponsor and the wallet cannot disagree about a byte.
  • Key: the sponsor's ML-DSA-65 key is a file on bob readable only by blackbeard, generated on bob and never in the repo or CI.
  • Off by default: without a [near_sponsor] config section, both POSTs answer 503 and the terms say enabled: false.
  • Submission: to gargravarr, which tracks the sponsor's shard (8). Transactions are serialised through one nonce counter.

Known gap: on a 1Click leg, the fee is in the quote's appFees, which the relayer does not see. It only sees an mt_transfer to a deposit account. Enforcing that fee would mean the relayer looking the quote up; noted rather than built.

The observer's side of blackbeard/wallet#81. Read that issue for the decisions. In short: `blackbeard-observer.near` creates each wallet's NEAR account, then relays its legs as NEP-366 meta-transactions and pays the gas. A swap fee (wallet#82) pays for it. Nothing the relayer refuses reaches NEAR. **Endpoints** - `GET /v1/near/sponsor`: the terms. Sponsor account, fee in bps and its recipient, the relay rules, and whether the sponsor is enabled. - `POST /v1/near/accounts` `{ public_key: "ml-dsa-65:<base58>" }`: creates `b<…>.blackbeard-observer.near` for that key, in one transaction: `CreateAccount`, `Transfer` of NEAR's storage minimum, `AddKey`. If it already exists with that key, it is returned. Idempotent by construction: the name is a function of the key. - `POST /v1/near/relay` `{ signed_delegate: base64 }`: decoded and verified with `wallet-near`, checked against the rules, wrapped in a transaction from the sponsor and submitted. Returns the transaction hash. **Rules** (in `blackbeard-core`, no I/O, unit-tested with delegate actions built by `wallet-near`): - **sender:** the sponsored name of the delegate's own key; - **receiver:** `intents.near` or `wrap.near`; - **actions:** function calls only, from a fixed list of methods, gas capped per method, deposits limited to what those methods need; - **fee:** a pool-swap `ft_withdraw` to `dclv2.ref-labs.near` must come with the fee's `mt_transfer` in the same delegate action. The fee is in the input token, at least `ceil(amount × bps / 10000)`, to the fee recipient. **Limits:** per sender, per client address, and a daily cap on relayed transactions. **Shape:** - **Code:** `wallet-near` comes from the wallet repo by git rev, so the sponsor and the wallet cannot disagree about a byte. - **Key:** the sponsor's ML-DSA-65 key is a file on bob readable only by `blackbeard`, generated on bob and never in the repo or CI. - **Off by default:** without a `[near_sponsor]` config section, both POSTs answer 503 and the terms say `enabled: false`. - **Submission:** to gargravarr, which tracks the sponsor's shard (8). Transactions are serialised through one nonce counter. **Known gap:** on a 1Click leg, the fee is in the quote's `appFees`, which the relayer does not see. It only sees an `mt_transfer` to a deposit account. Enforcing that fee would mean the relayer looking the quote up; noted rather than built.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: blackbeard/observer#51