PolymarketClob.Auth.L1 (PolymarketClob v0.2.0)

Copy Markdown View Source

Level 1 EIP-712 authentication for CLOB API-key derivation.

Polymarket's current ClobAuth message includes nonce; omitting it produces signatures that do not match the official v2 clients.

Summary

Functions

Builds L1 auth headers using the current Unix timestamp.

Builds L1 auth headers for an explicit, caller-supplied timestamp.

Signs a ClobAuth message and returns a 0x-prefixed Ethereum signature.

Functions

headers(private_key, address, chain_id, nonce \\ 0)

@spec headers(String.t() | binary(), String.t(), integer(), integer()) :: map()

Builds L1 auth headers using the current Unix timestamp.

To supply your own timestamp, use headers_at/5. This arity intentionally takes only the nonce as its last argument so a caller-supplied timestamp can never be silently bound to the wrong positional and replaced by system time.

headers_at(private_key, address, chain_id, timestamp, nonce)

@spec headers_at(String.t() | binary(), String.t(), integer(), integer(), integer()) ::
  map()

Builds L1 auth headers for an explicit, caller-supplied timestamp.

Prefer this over headers/4 whenever you need a specific timestamp: every positional argument has a stable meaning here, so the timestamp can never be mistaken for the nonce.

sign(private_key, address, chain_id, timestamp, nonce)

@spec sign(String.t() | binary(), String.t(), integer(), integer(), integer()) ::
  String.t()

Signs a ClobAuth message and returns a 0x-prefixed Ethereum signature.