Authentication & Signing
API wallets (Agents), EIP-712 signing flows, and nonce rules for POST /exchange.
Read-only POST /info queries and public WebSocket channels require no authentication. All POST /exchange write actions require an EIP-712 signature.
API Wallets (Agents)
Instead of keeping your main wallet private key on a trading server, you can authorize a dedicated Agent wallet via approveAgent (or approveAgentScoped for restricted scopes):
- Allowed: Sign trading actions (
order,cancel,modify,batchModify,batchModifyAtomic,massQuote,updateLeverage,updateIsolatedMargin,scheduleCancel,twapOrder,twapCancel,setStpMode,setEntityStp), bind referral codes & claim rewards, and trade sub-accounts viavaultAddress. - Forbidden: Withdrawals (
withdraw3), external transfers (usdSend,spotSend,usdClassTransfer), sub-account creation/transfers, builder or agent approvals, multi-sig conversion,reserveRequestWeight, and Protocol Vault deposits/redemptions/cancellations (userVaultTransfer/userProtocolVaultCancel). - Quotas & Expiry: Up to
3 + 2 × n_subaccountsnamed agents (max 103) plus 1 unnamed agent per master (MMV operator multi-sig supports up to 64 strategy trading agents). Maximum validity 180 days; target agent addresses must be fresh (no prior balance, nonce, or role).
Two Signing Flows
1. L1 Agent Actions (Trading)
Used for: order, cancel, cancelByCloid, cancelAll, modify, batchModify, batchModifyAtomic, massQuote, updateLeverage, updateIsolatedMargin, scheduleCancel, twapOrder, twapCancel, setStpMode, setEntityStp.
Step 1 — Compute connectionId
Serialize action with MessagePack, append the 8-byte big-endian nonce, the vault flag/bytes, and optional expires, then hash with keccak256:
connectionId = keccak256(msgpack(action) || nonce_be8 || vault || expires)vault:0x00ifvaultAddressis omitted; otherwise0x01 || vaultAddress (20 bytes).expires: omitted ifexpiresAfteris unset; otherwise0x00 || expiresAfter_be8.
Step 2 — Sign EIP-712 Agent Typed Data
- Domain:
{ name: "vperp", version: "1", chainId: <VCORE_CHAIN_ID> }(noverifyingContract) - Primary Type:
Agent - Types:
Agent: [{ name: "source", type: "string" }, { name: "connectionId", type: "bytes32" }] - Message:
{ source, connectionId }
| Environment | source |
|---|---|
| Mainnet | "oc" |
| Testnet | "oc-test" |
| Devnet | "oc-dev" |
2. User-Signed Actions (Transfers, Withdrawals, Vaults & Approvals)
Used for: usdClassTransfer, usdSend, spotSend, sendAsset, withdraw3, userVaultTransfer, userProtocolVaultCancel, approveAgent, approveAgentScoped, approveBuilderFee, convertToMultiSigUser.
Signed directly by the master wallet (trading agents are strictly rejected):
- Domain:
{ name: "vperp", version: "1", chainId: <WALLET_EVM_CHAIN_ID> }(must matchsignatureChainIdin the action, e.g.,0x1,0xa4b1,0x2105) - Primary Type:
VPerpTransaction:<ActionName>(e.g.,VPerpTransaction:Withdraw,VPerpTransaction:ApproveAgent,VPerpTransaction:UsdClassTransfer) vperpChainfield:"VPerp"(Mainnet),"VPerpTestnet"(Testnet), or"VPerpDevnet"(Devnet).
Do Not Mix Environment Parameters
Always verify source, vperpChain, and chainId against the target environment. Testnet signatures are rejected on Mainnet.
Nonce Rules
Each user or Agent signer maintains a sliding window of its 100 highest accepted nonces:
- Use the current Unix timestamp in milliseconds as
nonce. - Must be non-zero, unused, and within
[block_time - 2 days, block_time + 1 day]. - Must be strictly greater than the smallest nonce currently in the 100-item window.
- Non-monotonic concurrent requests are allowed as long as each nonce is unique and stays above the window floor.