SDK/MCP

Private-flow tools

TESTNET

The v1 private loan tools (essey_private_offer, essey_private_settle, essey_private_cancel, essey_private_repay, essey_private_offer_commit) are legacy. v1 settle publishes every losing rate. Use the v2 tools. essey_private_offer_commit draws a salt of at least 128 bits when you omit salt.

A pure MCP agent, with no SDK code of its own, runs every private flow through these tools. The server requires an agent key file before it starts, even to list these tools. It reads the path only from ESSEY_AGENT_KEY_FILE. That variable is required and has no default. From the project that installed the packages, this writes a mode-600 testnet file and prints the new address: node --input-type=module -e "import { createAgentKeyFile } from '@esseyonsui/sui-sdk'; console.log(createAgentKeyFile('agent.env', 'testnet'))". That command only writes the key file. Point the server at it with ESSEY_AGENT_KEY_FILE=agent.env. essey-sui-init --key writes the same kind of file when that path is missing. essey_shielded_deposit is a real pool::deposit (address balance, including SUI). essey_prove_pass asks the hosted issuer for a credential and proves membership in-process with @esseyonsui/proving-keys-testonly. essey_shielded_scan, essey_shielded_withdraw and essey_shielded_exit use that seed; withdraw and exit go through the relayer. essey_sale_open_v2, essey_sale_attest_v2, essey_sale_bid_v2, essey_sale_finish_v2, essey_sale_collect_v2, essey_sale_claim_v2, essey_sale_cancel_v2 and essey_sale_expire_v2 cover a shielded sale. essey_loan_open_v2, essey_loan_attest_v2, essey_loan_offer_v2, essey_loan_settle_v2, essey_loan_repay_v2, essey_loan_cancel_v2, essey_loan_claim_default_v2 and essey_loan_liquidate_v2 cover a private loan, both sides, for USDC, SUI and tUSDsui. Finish and settle open Seal after close and prove Settle(16) with @esseyonsui/settle-keys-testonly. Bids and offers are bid_v2 and loan_offer_v2 on the relayer. essey_shielded_recover keeps a lender note whose ciphertext was empty. essey_sealed_bid encrypts a wallet-room offer with Seal. essey_private_rooms lists v2 rooms. Set ESSEY_SHIELDED_STATE to the mode-600 seed file. ESSEY_STATE is the optional file essey_owner_setup_result writes; the running server does not reload it. The seed, openings and salts are mode 600 and are never returned. A process with no ESSEY_TREASURY can run only these private tools. essey_rooms lists only sealed wallet loan rooms. essey_faucet with coin: "SUI" returns the Sui CLI and https://faucet.sui.io instructions (compatibility_disabled on the HTTP gas route). essey_owner_setup_result reads a setup digest and returns treasury and cap ids. Save GET /v1/private/config as ESSEY_PRIVATE and use it as-is. Each loanMarkets.<coin> object keeps its id, oraclePkg, feed and reader (the served collateral, loan, quote, openable and witness are ignored). essey_loan_open_v2 reads that oracle. graceMs on the response is the chain constant 300000.

The testnet SUI pool insert fee is 0.1 SUI per essey_shielded_deposit. A SUI essey_sale_bid_v2 or essey_loan_offer_v2 pays that fee twice more, once for the change note and once for the refund, so the note must hold about 0.212 SUI (max price or principal, plus the 0.01 SUI relayer fee, plus 0.2 SUI) and depositing it costs another 0.1 SUI. A SUI loan essey_loan_repay_v2 pays owed plus another 0.1 SUI. One faucet grant is about 1 SUI. That is enough for a bidder's deposit or for a seller's open, attest and finish (finish and settle each reserve a 0.25 SUI gas budget). One address that runs a full SUI sale and a full SUI loan, including the deposit, needs a second grant: request the faucet again, and on a rate limit wait and retry or use another address.

On a fresh install, the first private call can take up to a few minutes while the proving keys download. Once those keys are cached, the same call is much shorter. Call essey_shielded_scan once before opening or offering, so that work finishes before the offer window starts. For an MCP-driven room, set offerWindowMs to at least 600000. An offer that arrives after the window is refused with abort 8 in room::admit_offer (offer after the offer window closed).

essey_shielded_withdraw refuses amount less than or equal to the relayer fee with ZERO_WITHDRAW before it proves. That amount is what the recipient receives; the fee is on top. essey_shielded_recover returns the note's coin. After a default or liquidation that coin is the seized collateral (the SUI pool when the loan was USDC), and warning is set when it differs from the coin you passed. essey_sale_bid_v2 echoes your own price in the result. That price is not on the bid. Avoid logging the result. essey_loan_offer_v2 echoes your own rateBps the same way: a lender that wants its rate kept sealed keeps tool results out of its logs.

Set ESSEY_PRIVATE to the path of the private-flow ids file (packages, Access, PassKey, coin types, and loanMarkets ids) and the MCP server adds these tools. The build-only private tools return unsigned bytes for sender, a relayer or a fresh wallet. Sui Dollar (USDsui) is the default loan coin. Its collateral is SUI. A SUI loan's collateral defaults to Sui Dollar. loanCoin: "SUI" with collateralCoin: "SUI" is refused.

ToolWhoWhat it returns
essey_private_infoAnyonePackages, Access, coin types, and loanMarkets (one id per loan coin; all three are open on testnet)
essey_private_offer_commitLenderThe sealed-rate commitment commitOf(rate, salt) and the payload the pool proof must bind, computed locally
essey_private_action_bindingBorrowerThe action hash a relayed credential must be bound to, over the room, a nonce and every argument
essey_private_offerLenderA sealed-rate offer funded from the shielded pool; room credential and gate pass (omitted in PUBLIC) bound to spend.n0
essey_private_settleBorrower (relayed)Opens the sealed offers and settles the principal into the borrower's note
essey_private_cancelBorrower (relayed)Cancels an unsettled private loan room
essey_private_repayBorrowerRepays exactly what is owed from a shielded note; the lender's repay note is fixed by the room
essey_private_sale_pool_bidMemberA shielded sale bid: gate pass (omitted in PUBLIC) and room credential, both bound to spend.n0
essey_private_offer_commit_v2LenderFor a private_room_v2 offer: commit = Poseidon(rateBps, salt) and the 40-byte opening to Seal for the borrower; a random salt when none is given, a salt below 2^128 refused. Computed locally
essey_private_action_binding_v2BorrowerThe v2 action hash a relayed private_room_v2 credential must be bound to, over the room, a nonce and every argument, the proof included
essey_private_offer_v2LenderA committed offer into a private_room_v2 room, funded from the shielded pool; room credential and gate pass (omitted in PUBLIC) bound to spend.n0. One offer per member per room
essey_private_settle_v2Borrower (relayed)Settles a private_room_v2 room on the winning offer with a proof, never the losing values; the principal goes into the borrower's note. Its relayBody is posted as kind=settle_relayed_v2
essey_private_sale_pool_bid_v2MemberA shielded sale_room_v2 bid: gate pass (omitted in PUBLIC) and room credential bound to spend.n0, commit = Poseidon(price, salt) and the claim commitment in the pool proof's payload. One bid per member per room

The five _v2 tools are bound only when the ESSEY_PRIVATE file carries that package's section (privateLoanV2, saleRoomV2).

Commit arguments#

essey_private_offer_commit and essey_private_offer_commit_v2 take rateBps as a decimal string ("800") or as a JSON number when it is a safe integer. A value that does not fit a safe integer stays a string. sealed is even-length hex. The canonical form is 0x-prefixed ("0x03"); a bare hex string of even length is accepted. repayPubkey and repayBlinding stay decimal field strings.

JSON
{ "rateBps": "800", "sealed": "0x03", "repayPubkey": "1", "repayBlinding": "2" }

{ "rateBps": 800, "sealed": "03" } is the same call.

Hosted relayer kinds#

essey_private_settle and essey_private_repay return unsigned bytes for sender. The agent key never signs them. The hosted relayer does not execute those txBytes. It accepts a checked kind on POST /relay/<coin> (sui, usdc, or usdsui), rebuilds the same Move call the SDK builds (settlePrivateLoanRelayed, repayPrivateLoan), dry-runs it, and signs with the relayer key only.

loanPool, loanCoin, and collateralCoin are not fields of the hosted body. The route's pool and coin are the only pool and loan coin, and the room object must already name that pool. There is no repay_relayed function. private_room::repay is the relayed repayment: anyone can send it, and the proof binds the room's owed. repay_coin spends a public coin and is refused.

GET/healthz

Stays HTTP 200 with ok: true, and adds kinds: bid, withdraw, loan_offer, settle_relayed, repay, bid_v2, loan_offer_v2, settle_relayed_v2. The route and address are relayer.baseUrl + relayer.paths.<coin> and relayer.address of GET /v1/private/config.

The two v2 spend kinds, bid_v2 and loan_offer_v2, are what the essey_private_sale_pool_bid_v2 and essey_private_offer_v2 tools build a transaction for; the relayer takes the same fields as a body and sends it from its own key. The SDK builds these bodies: bidV2Body and loanOfferV2Body from the parts, or buildPoolBidV2 / buildOfferV2, which prove the spend and return the body as body (see Private flows with the SDK). essey_private_settle_v2 returns its relayBody for settle_relayed_v2.

essey_private_settle → kind=settle_relayed#

MCP argumentHosted field
sendersender (must be this relayer's address)
roomIdroom
noncenonce (must be the room's current nonce)
passpass (tag, expiryMs, 128-byte proof)
rates, saltsrates, salts (one per offer; an empty salt leaves that offer unrevealed)
principalPubkey, principalBlinding, encNotethe same names
essey_private_action_binding for these argumentsaction (the relayer recomputes settleAction and refuses a mismatch)
JSON
{
  "kind": "settle_relayed",
  "sender": "0x1111111111111111111111111111111111111111111111111111111111111111",
  "room": "0x2222222222222222222222222222222222222222222222222222222222222222",
  "nonce": "0",
  "action": "3",
  "pass": {
    "tag": "7",
    "expiryMs": "1893456000000",
    "proof": "0xabababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab"
  },
  "rates": ["900"],
  "salts": ["0x11111111111111111111111111111111"],
  "principalPubkey": "11",
  "principalBlinding": "13",
  "encNote": "0x010203"
}

The proof and action above are placeholders. A real pass is proved for action, which is essey_private_action_binding over this room, nonce, and these arguments.

essey_private_repay → kind=repay#

The MCP spend.proof inside txBytes is already the 128-byte chain proof. The hosted body takes the snarkjs Groth16 proof, the same shape as kind=loan_offer, and the relayer converts it with the pool verification key. publicSignals is repayStatement over the room's owed, the pool's insert_fee, and ext with refund pubkey and blinding fixed at 0. Do not send refundPubkey or refundBlinding.

MCP argumentHosted field
sender and spend.relayerext.relayer
roomIdext.room
spend.root, n0, n1, c0, c1publicSignals indexes 0, 3, 4, 5, 6
spend.feeext.fee
spend.encOut1, spend.encOut2ext.encOut1, ext.encOut2
lenderEnclenderEnc
JSON
{
  "kind": "repay",
  "proof": {
    "pi_a": ["1", "2", "1"],
    "pi_b": [["3", "4"], ["5", "6"], ["1", "0"]],
    "pi_c": ["7", "8", "1"],
    "protocol": "groth16",
    "curve": "bn128"
  },
  "publicSignals": ["11", "22", "33", "12", "13", "14", "15"],
  "ext": {
    "room": "0x2222222222222222222222222222222222222222222222222222222222222222",
    "relayer": "0x1111111111111111111111111111111111111111111111111111111111111111",
    "fee": "10000000",
    "encOut1": "0x01",
    "encOut2": "0x02"
  },
  "lenderEnc": "0x03"
}

Placeholder signals are refused (publicAmount / extDataHash / root). A live body uses the member's proof against the room's current owed.

essey_private_sale_pool_bid_v2 → kind=bid_v2#

A v1 bid body plus the commitment, the claim commitment and the two spend-bound credentials. The hosted body takes the snarkjs Groth16 proof, as kind=repay does, and the relayer converts it with the pool verification key. publicSignals is the seven signals root, publicAmount, extDataHash, n0, n1, c0, c1, and must equal saleBidStatementV2(rows, room.maxPrice, insertFee, ext, salePayloadV2(commit, claimCommit, sealed)): the spend escrows the room's ceiling, and the proof binds the payload, not sealed alone. Every number is a canonical decimal string, every byte string 0x hex.

MCP argumentHosted field
sender and spend.relayerext.relayer (must be this relayer's address)
roomIdext.room (a SaleRoom of the configured sale_room_v2 package)
spend.root, n0, n1, c0, c1publicSignals indexes 0, 3, 4, 5, 6
spend.feeext.fee (at least the route's floor, below the pool's max_fee)
refundPubkey, refundBlindingext.refundPubkey, ext.refundBlinding (field elements)
spend.encOut1, spend.encOut2ext.encOut1, ext.encOut2
commitcommit (a field element, Poseidon(price, salt))
claimCommitclaimCommit (32 bytes, blake2b256(claimTo ‖ salt))
sealedsealed (the Seal ciphertext of the 40-byte opening, sealed under bid_key_id(room, nextSeq) with AAD bcs(n0))
membermember (tag, expiryMs, 128-byte proof; the room credential bound to n0; required)
gategate (the same shape for the Access, or null; omit in PUBLIC)
pool, itemType, coinnot fields: the route's pool and coin, and the item type is read from the room
JSON
{
  "kind": "bid_v2",
  "proof": { "pi_a": ["1", "2", "1"], "pi_b": [["3", "4"], ["5", "6"], ["1", "0"]], "pi_c": ["7", "8", "1"], "protocol": "groth16", "curve": "bn128" },
  "publicSignals": ["11", "22", "33", "12", "13", "14", "15"],
  "ext": {
    "room": "0x2222222222222222222222222222222222222222222222222222222222222222",
    "relayer": "0x1111111111111111111111111111111111111111111111111111111111111111",
    "fee": "10000000",
    "refundPubkey": "17",
    "refundBlinding": "19",
    "encOut1": "0x01",
    "encOut2": "0x02"
  },
  "sealed": "0x03",
  "commit": "23",
  "claimCommit": "0x2929292929292929292929292929292929292929292929292929292929292929",
  "member": { "tag": "7", "expiryMs": "1893456000000", "proof": "0xabab…ab" },
  "gate": null
}

Placeholder signals are refused. The relayer refuses, without sending: a body without member; a claimCommit that is not 32 bytes; ext.relayer not its own address; a fee under the route's floor or at or above the pool's max_fee; a root it has not read as current (STALE_ROOT: scan and prove again); a room that is not a SaleRoom of the configured v2 package; a publicAmount that is not the room's max_price plus fee plus the insert fees; an extDataHash that does not match ext and the bid payload_of. The chain then refuses what buildPoolBidV2 lists.

essey_private_offer_v2 → kind=loan_offer_v2#

The same spend shape as bid_v2; commit is a field element (v1's loan_offer carried 32 bytes), and the repay note replaces the claim commitment. publicSignals must equal loanOfferStatementV2(rows, room.principal, insertFee, ext, loanPayloadV2(commit, repayPubkey, repayBlinding, sealed)): the spend escrows the room's principal.

MCP argumentHosted field
sender and spend.relayerext.relayer (must be this relayer's address)
roomIdext.room (a PrivateLoanRoom of the configured private_room_v2 package, in state bidding)
spend.root, n0, n1, c0, c1publicSignals indexes 0, 3, 4, 5, 6
spend.feeext.fee
refundPubkey, refundBlindingext.refundPubkey, ext.refundBlinding
spend.encOut1, spend.encOut2ext.encOut1, ext.encOut2
commitcommit (a field element, Poseidon(rateBps, salt))
sealedsealed (sealed under offer_key_id(room, nextSeq) with AAD bcs(n0))
repayPubkey, repayBlindingrepayPubkey, repayBlinding (field elements: the lender's note the repayment lands in)
passmember (the room credential bound to n0; required)
gategate (or null; omit in PUBLIC)
loanPoolnot a field: the route's pool is the room's loan_pool
JSON
{
  "kind": "loan_offer_v2",
  "proof": { "pi_a": ["1", "2", "1"], "pi_b": [["3", "4"], ["5", "6"], ["1", "0"]], "pi_c": ["7", "8", "1"], "protocol": "groth16", "curve": "bn128" },
  "publicSignals": ["11", "22", "33", "12", "13", "14", "15"],
  "ext": {
    "room": "0x2222222222222222222222222222222222222222222222222222222222222222",
    "relayer": "0x1111111111111111111111111111111111111111111111111111111111111111",
    "fee": "10000",
    "refundPubkey": "17",
    "refundBlinding": "19",
    "encOut1": "0x01",
    "encOut2": "0x02"
  },
  "sealed": "0x03",
  "commit": "23",
  "repayPubkey": "31",
  "repayBlinding": "37",
  "member": { "tag": "7", "expiryMs": "1893456000000", "proof": "0xabab…ab" },
  "gate": null
}

The refusals are bid_v2's, with the room checks of a loan room: another pool than the room's loan_pool, a room not taking offers, a publicAmount that is not the room's principal plus fee plus the insert fees. One offer per member per room, by credential tag.

Wallet loan room and v1 sales#

essey_loan_settle_v2 takes relayed: true to POST kind: "settle_relayed_v2" instead of signing room::settle. Losing rates stay off that body.

The wallet loan room (address mode, v1 loan_room, settle publishes every losing rate) is essey_wallet_loan_open, essey_wallet_loan_bid, essey_wallet_loan_open_bids, essey_wallet_loan_settle, essey_wallet_loan_repay, essey_wallet_loan_decline and essey_wallet_loan_refund. Open-bids stores salts in the mode-600 file and does not return them.

A v1 sale room, in order, is essey_sale_open_v1, essey_sale_attest_v1 (required; every bid aborts 23 until it lands), essey_sale_bid_address_v1 or essey_sale_bid_v1 (coin USDC, USDSUI or SUI), essey_sale_finish_v1 or essey_sale_expire_v1, essey_sale_collect_v1, and essey_sale_claim_v1. Finish publishes every bid. A v1 room takes address bids or pool bids, set by shieldedOnly on essey_sale_open_v1 (default false). With false, essey_sale_bid_address_v1 lands and essey_sale_bid_v1 aborts room::push_pool_bid 17 ENotShieldedRoom. With true, essey_sale_bid_v1 lands and an address bid aborts room::bid 16 EShieldedRoom. The refused bid is not sent, and a shielded deposit made for it stays an unspent note for the next bid or an exit. To take both kinds, open one room of each. A v2 sale stays on the *_v2 tools.