sponsor: blackbeard-observer.near creates each wallet's NEAR account and relays its legs, paying the gas #81

Open
opened 2026-10-09 10:08:08 +00:00 by grenade · 1 comment
Owner

Part of #71. Operator decisions 2026-10-09:

  • a sponsor service, paid for by the swap fee (#82);
  • the sponsor relays (NEP-366 meta-transactions) rather than handing each account a gas float.

Why a relayer

A float can be farmed: anyone can make keys and sweep each new account's float, and rate limits only slow that down. With a relayer the user signs a delegate action with their ML-DSA-65 key; the sponsor wraps it in its own transaction and pays the gas. The account holds no spendable NEAR beyond NEAR's storage minimum (about 0.002 NEAR), and the user never sees NEAR at all.

Proven on mainnet 2026-10-09 (a one-off outside any repo): bbspike72.near signed an ML-DSA-65 delegate action (wrap.near.storage_deposit) and relayed it, in transaction 2SVwJsa1seKQHvAJ2JCzaBvAq8cLfJSPJtppxkr9ahK4.

  • 10,762 bytes with two ML-DSA signatures; the delegate action alone is 5,418.
  • The inner call ran (wrap.near logged "already registered, refunding the deposit").
  • Format: the classic Delegate action (tag 8). It is signed over SHA-256(u32 LE 2^30 + 366 ‖ borsh DelegateAction), and the delegate nonce shares the sender key's counter.

The account

  • blackbeard-observer.near (free on 2026-10-09; shard 8). Its name says where its terms are.
  • Its own key is ML-DSA-65. It is created through the registrar with a temporary ed25519 key that is then replaced and deleted, as #72 did.
  • The operator funds it.

Creating a wallet's account

  • One transaction from the sponsor: CreateAccount, Transfer (NEAR's storage minimum only) and AddKey (the wallet's ML-DSA-65 key, full access).
  • The name is a function of the key: b<lowercase unpadded base32 of the first 10 bytes of the key's handle digest>.blackbeard-observer.near.
    • A restored phrase finds its account with nothing stored.
    • The leading b sorts it onto shard 8, which we serve.
    • Implemented wallet-side in wallet_core::near::sponsored_account.

Relaying

The sponsor relays only what the wallet's routes need, and refuses everything else:

  • sender: a *.blackbeard-observer.near account;
  • receiver: intents.near or wrap.near;
  • actions: function calls only, from a fixed list of methods (ft_withdraw, mt_transfer, ft_transfer_call, near_deposit, storage_deposit), with gas capped per method;
  • deposits: at most the 1 yoctoNEAR those methods require, plus storage deposits;
  • the fee is mandatory: a pool-swap ft_withdraw to dclv2.ref-labs.near is relayed only if the same delegate action carries #82's fee mt_transfer to the fee account. The relayer is what makes the fee binding, not the wallet's goodwill.

The service

On blackbeard.observer's API:

  • GET /v1/near/sponsor: the account, the fee in bps and its recipient, the limits and the relay rules.
  • POST /v1/near/accounts: an ML-DSA-65 public key in, the created (or already existing) account out. Idempotent by construction.
  • POST /v1/near/relay: a signed delegate action in; it is checked against the rules above and submitted. Returns the transaction hash.
  • Limits: per sender and per client address, and a daily NEAR budget across everyone.

The sponsor's key lives on bob, readable by the API's user only, installed by infra-setup.sh and never by CI.

Shared code

The NEP-649 key, the transaction encoder and the delegate-action encoder move from wallet-data into a small crate in the wallet repo. The observer depends on it, rather than keeping a second implementation.

Operator-owned: registering and funding the account; the limits and the daily budget.

Part of #71. Operator decisions 2026-10-09: - a sponsor service, paid for by the swap fee (#82); - the sponsor **relays** (NEP-366 meta-transactions) rather than handing each account a gas float. ## Why a relayer A float can be farmed: anyone can make keys and sweep each new account's float, and rate limits only slow that down. With a relayer the user signs a delegate action with their ML-DSA-65 key; the sponsor wraps it in its own transaction and pays the gas. The account holds no spendable NEAR beyond NEAR's storage minimum (about 0.002 NEAR), and the user never sees NEAR at all. **Proven on mainnet 2026-10-09** (a one-off outside any repo): `bbspike72.near` signed an ML-DSA-65 delegate action (`wrap.near.storage_deposit`) and relayed it, in transaction `2SVwJsa1seKQHvAJ2JCzaBvAq8cLfJSPJtppxkr9ahK4`. - 10,762 bytes with two ML-DSA signatures; the delegate action alone is 5,418. - The inner call ran (`wrap.near` logged "already registered, refunding the deposit"). - Format: the classic `Delegate` action (tag 8). It is signed over SHA-256(u32 LE `2^30 + 366` ‖ borsh `DelegateAction`), and the delegate nonce shares the sender key's counter. ## The account - **`blackbeard-observer.near`** (free on 2026-10-09; shard 8). Its name says where its terms are. - Its own key is ML-DSA-65. It is created through the registrar with a temporary ed25519 key that is then replaced and deleted, as #72 did. - The operator funds it. ## Creating a wallet's account - One transaction from the sponsor: `CreateAccount`, `Transfer` (NEAR's storage minimum only) and `AddKey` (the wallet's ML-DSA-65 key, full access). - **The name is a function of the key:** `b<lowercase unpadded base32 of the first 10 bytes of the key's handle digest>.blackbeard-observer.near`. - A restored phrase finds its account with nothing stored. - The leading `b` sorts it onto shard 8, which we serve. - Implemented wallet-side in `wallet_core::near::sponsored_account`. ## Relaying The sponsor relays only what the wallet's routes need, and refuses everything else: - **sender:** a `*.blackbeard-observer.near` account; - **receiver:** `intents.near` or `wrap.near`; - **actions:** function calls only, from a fixed list of methods (`ft_withdraw`, `mt_transfer`, `ft_transfer_call`, `near_deposit`, `storage_deposit`), with gas capped per method; - **deposits:** at most the 1 yoctoNEAR those methods require, plus storage deposits; - **the fee is mandatory:** a pool-swap `ft_withdraw` to `dclv2.ref-labs.near` is relayed only if the same delegate action carries #82's fee `mt_transfer` to the fee account. The relayer is what makes the fee binding, not the wallet's goodwill. ## The service On blackbeard.observer's API: - `GET /v1/near/sponsor`: the account, the fee in bps and its recipient, the limits and the relay rules. - `POST /v1/near/accounts`: an ML-DSA-65 public key in, the created (or already existing) account out. Idempotent by construction. - `POST /v1/near/relay`: a signed delegate action in; it is checked against the rules above and submitted. Returns the transaction hash. - Limits: per sender and per client address, and a daily NEAR budget across everyone. The sponsor's key lives on bob, readable by the API's user only, installed by `infra-setup.sh` and never by CI. ## Shared code The NEP-649 key, the transaction encoder and the delegate-action encoder move from `wallet-data` into a small crate in the wallet repo. The observer depends on it, rather than keeping a second implementation. Operator-owned: registering and funding the account; the limits and the daily budget.
grenade added the child label 2026-10-09 10:08:08 +00:00
grenade changed title from sponsor: blackbeard-observer.near creates each wallet's NEAR account, with a gas float to sponsor: blackbeard-observer.near creates each wallet's NEAR account and relays its legs, paying the gas 2026-10-09 10:29:17 +00:00
Author
Owner

The sponsor account exists, 2026-10-09:

  • Registration: blackbeard-observer.near was registered from the operator's implicit account (tx At7zrH8TdYbcAmPtbjFM3RnNvSxjAZEvpJYpuvVYmir3), opening balance 0.01 NEAR.
  • Its only access key is an ML-DSA-65 key generated on bob as blackbeard (/var/lib/blackbeard/near-sponsor.key, mode 600). Handle ml-dsa-65-hash:4ct7C4TKKT7xBXbeBycyypUxgMLt5gxgdevwJvh5sxhu.
    • Only the key's public half left bob.
    • The registrar's temporary ed25519 key was deleted in the same transaction that added it (tx 44Ex8w8gqBUpC63pddvhR6KyV2E6PtzszZ9ngprosWoF).
  • Enabled in the observer (observer c36d08b) on the operator's terms:
    • 30 bps fee, paid to blackbeard-observer.near;
    • 0.0025 NEAR per created account;
    • at most 300 transactions a UTC day.

Costs, measured from #72's transactions:

  • creating an account: about 0.003 NEAR (0.0021 of it storage), so the first 300 cost about 0.9 NEAR;
  • relaying a sell route: about 0.005 NEAR (pool swap with its fee about 0.0035, then a 1Click transfer and a cash-out about 0.0008 each);
  • at 30 bps, the fee covers the gas on any swap above about $8.

The operator is funding it with about 6 NEAR.

Correction: the deposit in the first example config, 0.002 NEAR, was below a sponsored account's storage, and creation would have failed. It was fixed to 0.0025 before the sponsor was enabled.

The sponsor account exists, 2026-10-09: - **Registration:** `blackbeard-observer.near` was registered from the operator's implicit account (tx `At7zrH8TdYbcAmPtbjFM3RnNvSxjAZEvpJYpuvVYmir3`), opening balance 0.01 NEAR. - **Its only access key** is an ML-DSA-65 key generated on bob as `blackbeard` (`/var/lib/blackbeard/near-sponsor.key`, mode 600). Handle `ml-dsa-65-hash:4ct7C4TKKT7xBXbeBycyypUxgMLt5gxgdevwJvh5sxhu`. - Only the key's public half left bob. - The registrar's temporary ed25519 key was deleted in the same transaction that added it (tx `44Ex8w8gqBUpC63pddvhR6KyV2E6PtzszZ9ngprosWoF`). - **Enabled in the observer** (observer `c36d08b`) on the operator's terms: - 30 bps fee, paid to `blackbeard-observer.near`; - 0.0025 NEAR per created account; - at most 300 transactions a UTC day. **Costs, measured from #72's transactions:** - creating an account: about 0.003 NEAR (0.0021 of it storage), so the first 300 cost about 0.9 NEAR; - relaying a sell route: about 0.005 NEAR (pool swap with its fee about 0.0035, then a 1Click transfer and a cash-out about 0.0008 each); - at 30 bps, the fee covers the gas on any swap above about $8. The operator is funding it with about 6 NEAR. **Correction:** the deposit in the first example config, 0.002 NEAR, was below a sponsored account's storage, and creation would have failed. It was fixed to 0.0025 before the sponsor was enabled.
grenade referenced this issue from a commit 2026-10-09 21:39:00 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: blackbeard/wallet#81