UserClient
Test wallet helper for simulating user signing in Builder mode.
UserClient holds a private key and can sign EIP-712 typed data and order hashes. It is a testing utility -- in production, users sign with their own wallets (MetaMask, WalletConnect, etc.).
Create a Random Test Wallet
import { UserClient } from '@opinion-labs/opinion-clob-sdk';
const user = UserClient.createRandom();
console.log(user.address); // Random EOA addressCreate from Private Key
const user = new UserClient('0xYourPrivateKey...');
console.log(user.address); // Derived EOA addressSign Safe Transactions
Use signTypedData() for Safe transaction signing (enable trading, split, merge, redeem, withdraw):
const txResult = await builder.buildEnableTradingTx(safeAddress);
const signature = await user.signTypedData(txResult.eip712Data);
await builder.submitSafeTx(userAddress, txResult, signature);Parameters
typedData
TypedData
EIP-712 typed data with domain, types, primaryType, and message
Returns a hex signature string (0x-prefixed).
Sign Order Hashes
Use signHash() for order signing (place order):
Parameters
hashToSign
string
Hash to sign (hex string, with or without 0x prefix)
Returns a hex signature string (0x-prefixed).
File Persistence
For demo scripts, UserClient supports saving and loading from JSON files:
Notes
Order signing uses
signHash(structHash)-- signs the hash directly.Safe TX signing uses
signTypedData(eip712Data)-- signs EIP-712 typed data.These are two distinct signing patterns. Do not mix them up.
In production, replace
UserClientwith wallet integration (MetaMasketh_signTypedData_v4for Safe TXs,personal_signfor order hashes).
Last updated