package polymarket

  1. Overview
  2. Docs
OCaml client library for the Polymarket prediction market API

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.2.0.tar.gz
md5=4eb4c5d2f63ff081c9713d90be5a51b2
sha512=0e3de0c9b40683e09ab8f9f966a44784ef1b9b482c3eefef84104a7e8042c92f1d79893ee9588b24fa3d0decaed7f365509f4d1c23c66ce8328efb64e721f276

doc/polymarket.common/Polymarket_common/Crypto/index.html

Module Polymarket_common.CryptoSource

Cryptographic utilities for Polymarket API authentication.

This module provides EIP-712 signing for L1 authentication, HMAC-SHA256 signing for L2 authentication, and Ethereum address derivation.

Types

Sourcetype private_key

Abstract type for a 32-byte private key (64 hex chars, no 0x prefix).

Sourceval private_key_of_string : string -> private_key

Create a private key from a hex string (64 chars, no 0x prefix).

Sourceval private_key_to_string : private_key -> string

Convert a private key to its hex string representation.

Hashing

Sourceval keccak256 : string -> string

Compute keccak256 hash of bytes, returns hex string with 0x prefix.

Sourceval keccak256_hex : string -> string

Compute keccak256 hash of hex-encoded data (no 0x prefix), returns hex string with 0x prefix.

HMAC-SHA256 for L2 Authentication

Sourceval hmac_sha256 : key:string -> string -> string

HMAC-SHA256 of message with raw key bytes, returns raw bytes.

Sourceval sign_l2_request : secret:string -> timestamp:string -> method_:string -> path:string -> body:string -> string

Generate L2 authentication signature. secret is base64-encoded. Returns base64-encoded signature.

EIP-712 for L1 Authentication

Sourceval sign_clob_auth_message : private_key:private_key -> address:string -> timestamp:string -> nonce:int -> string

Sign the CLOB authentication message using EIP-712. Returns hex signature with 0x prefix.

Utilities

Sourceval private_key_to_address : private_key -> string

Derive Ethereum address from private key. Returns 0x-prefixed address.

Sourceval current_timestamp_ms : unit -> string

Get current Unix timestamp in milliseconds as string.

Internal

Sourcemodule Private : sig ... end

For internal use only. Do not depend on this module.