Skip to main content

Binary Order Entry Session Keys

The owner wallet signs one delegation. The quote engine then signs each order locally with an Ed25519 session key. Wallet-signed TCP orders are acknowledged with 202 and not applied, so session keys are required for TCP order entry.

Steps​

  1. Read GET /api/v1/bsl/connectivity for actionSigning.chainId and verifyingContract.
  2. Create an Ed25519 key pair locally.
  3. Define a policy for one account, one gateway and the intended markets.
  4. Sign the EIP-712 SessionDelegationV2 with the owner wallet.
  5. Register the key with POST /api/v1/bsl/session-keys/register.
  6. Open the TCP connection and sign every frame with the session key.
  7. Revoke the key when the engine stops.

Endpoints​

RoutePurposeAuthorization
POST /api/v1/bsl/session-keys/registerRegister a keyOwner wallet signature in the body
POST /api/v1/bsl/session-keys/listList keysOwner wallet signature
POST /api/v1/bsl/session-keys/revokeRevoke a keyFresh wallet signature for revoke_session_key; never reuse the registration signature or nonce

Reference: register, list, revoke.

Registration rules​

RuleDetail
HeadersSend Origin of the registered app. Send no SC-* machine-auth headers; they cause 403
App identityappName and domain must match your registered app. The Sentico app uses appName: "Sentico", domain: "app.sentico-labs.xyz", Origin: https://app.sentico-labs.xyz
Signed fieldsNever change a signed app or domain field without a new signature
Chain idFrom the connectivity bundle of the host you use (42161 production)
Delegationsenticore_session_delegation_eip712_v2; EIP-712 domain name: SentiCore, version: 1, with chainId and verifyingContract from the bundle
Account idsDelegation accountIdHex is the 32-byte trading-account id from GET /api/v1/trading/accounts?owner=<wallet>. Order payloads use the 20-byte engine account
LifetimeAt most 24 hours; rotate on restart

Policy​

{
"allowedMarkets": [7],
"allowedActions": ["spot_place", "cancel"],
"maxOrderQtyLots": 1000000,
"maxNotionalMicro": 250000000,
"gatewayId": 1,
"cancelOnDisconnect": false
}
FieldBehavior
allowedMarketsEnforced per frame. Empty means all markets available to the account
allowedActionsplace, spot_place, cancel, amend, quote_replace, spot_quote_replace; each leg of a group must be allowed
maxOrderQtyLotsPer frame
maxNotionalMicroPer place frame
gatewayIdEnforced when set
cancelOnDisconnectWhen true, a TCP disconnect cancels the live orders admitted through this key. Place frames must carry a derived order id
maxOpenExposureMicro, sourceIpAllowlist, clientCertFingerprintNot supported; registration rejects them

Sign an order​

const encoded = encodeBslSessionOrder(payload, {
...routing, // from bslCompactRoutingFromConnectivityBundle(bundle)
accountIdx: routing.accountIdx,
sessionId: tcpSessionId, // fresh non-zero u64 per connection
gatewaySeq,
sessionPrivateKey: sessionKey.privateKey,
sessionKeyId: sessionKey.sessionKeyId,
sessionSeq, // persisted, strictly increasing
policyHash
});
for (const message of encoded.tcpMessages) socket.write(message);

Persist session_seq for every reused key. Never restart it at 1.

Sidecar forms​

Order shapeSidecarSigned action payload
Independent place, cancel or amendFixed binary form, 236 bytesOmitted
Atomic quote-replace groupJSON sidecars inside CompactFrameGroupRequired

Both forms enforce the registered policy and a chain-bound signature. See Framing.

Next steps​