Authentication Flow

// 1. Sign authentication message
const authMessage = {
  address: walletAddress,
  timestamp: Date.now(),
  nonce: 0,
  message: "This message attests that I control the given wallet"
};

// 2. Derive API credentials from signature
const signature = await wallet.signTypedData(domain, types, authMessage);
const credentials = deriveApiCredentials(signature);

// 3. Use credentials for CLOB API calls
const headers = {
  "POLY_ADDRESS": safeAddress,
  "POLY_SIGNATURE": apiSignature,
  "POLY_TIMESTAMP": timestamp,
  "POLY_API_KEY": apiKey
};

Last updated