From b63893932279eddd750d71bf4d5c89d112d0041a Mon Sep 17 00:00:00 2001 From: Oxyn Kuvatov Date: Thu, 12 Nov 2026 23:25:02 +0500 Subject: [PATCH] document Polymarket Safe tx signing on /wallet/sign and eth_sign typedData --- .../express-api/policy/transaction-data.mdx | 4 +- .../express-api/wallet-operations.mdx | 2 +- uoa/api-reference/wallet-operations.mdx | 66 ++++++++++++++++++- 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/server-wallets/express-api/policy/transaction-data.mdx b/server-wallets/express-api/policy/transaction-data.mdx index c569f51..8bcb876 100644 --- a/server-wallets/express-api/policy/transaction-data.mdx +++ b/server-wallets/express-api/policy/transaction-data.mdx @@ -42,7 +42,7 @@ The signing method being used. Valid values: - `eth_signTypedData` - Sign typed data (v1, legacy) - `eth_signTypedData_v3` - Sign EIP-712 typed data v3 - `eth_signTypedData_v4` - Sign EIP-712 typed data v4 -- `eth_sign` - Sign a message, sent in `data` +- `eth_sign` - Sign a message, sent in `data`. With `typedData`, `data` must be that typed data's EIP-712 hash - `eth_sign7702Authorization` - Sign an EIP-7702 authorization, with `chainId`, `address` and `nonce` - `personal_sign` - Evaluated by policy on [Sign Message](/server-wallets/express-api/wallet-operations#sign-message); not accepted on `sign/data` @@ -88,7 +88,7 @@ The EIP-7702 delegate contract. Required for `eth_sign7702Authorization`, togeth -EIP-712 typed data structure. Required for `eth_signTypedData_v3` and `eth_signTypedData_v4` methods. +EIP-712 typed data structure. Required for `eth_signTypedData_v3` and `eth_signTypedData_v4` methods. Optional for `eth_sign`, where it is the typed data whose EIP-712 hash is `data`. Follows the following structure: diff --git a/server-wallets/express-api/wallet-operations.mdx b/server-wallets/express-api/wallet-operations.mdx index 46fdf26..364e7ef 100644 --- a/server-wallets/express-api/wallet-operations.mdx +++ b/server-wallets/express-api/wallet-operations.mdx @@ -100,7 +100,7 @@ What you're signing. Required for `ETH`. Set `method` and the fields for it: | `eth_signTransaction`, `eth_sendTransaction` | `to`, `value`, `data`, `chainId`, `nonce`, `gasLimit`, and `maxFeePerGas` + `maxPriorityFeePerGas` (EIP-1559) or `gasPrice` (legacy) | The unsigned transaction hash | | `eth_signTypedData_v4`, `eth_signTypedData_v3` | `typedData`: the full EIP-712 JSON (`types`, `primaryType`, `domain`, `message`) | The EIP-712 hash | | `eth_signTypedData` | `typedData`: the v1 typed data array | eth-sig-util `typedSignatureHash` | -| `eth_sign` | `data`: the message, as `0x`-prefixed hex bytes or plain text | The EIP-191 hash | +| `eth_sign` | `data`: the message, as `0x`-prefixed hex bytes or plain text. To sign an EIP-712 hash this way (a Safe transaction for a relayer, for example), also send `typedData`: `data` must then be its EIP-712 hash, and the typed data is screened as signed | The EIP-191 hash of `data` | | `eth_sign7702Authorization` | `chainId`, `address` (the delegate contract), `nonce` | keccak256(0x05 ‖ rlp([chainId, address, nonce])) | See [EVM data preparation](/server-wallets/express-api/data-preparation/evm) for code that builds each one. Transactions with an access list, blobs or an authorization list are not supported here. diff --git a/uoa/api-reference/wallet-operations.mdx b/uoa/api-reference/wallet-operations.mdx index c2b9a20..f70368d 100644 --- a/uoa/api-reference/wallet-operations.mdx +++ b/uoa/api-reference/wallet-operations.mdx @@ -89,17 +89,77 @@ A plain text message to sign. It is signed as an EIP-191 (`personal_sign`) messa -EIP-712 typed data to sign, as `{"method": "eth_signTypedData_v4", "typedData": {...}}`. `typedData` has `types` (including `EIP712Domain`), `primaryType`, `domain` and `message`, as passed to `eth_signTypedData_v4`. The signature is over the typed data's EIP-712 digest, so it verifies with ethers' `verifyTypedData` (pass `types` without `EIP712Domain`). +What to sign, in one of two forms: + +- **EIP-712 typed data:** `{"method": "eth_signTypedData_v4", "typedData": {...}}`. `typedData` has `types` (including `EIP712Domain`), `primaryType`, `domain` and `message`, as passed to `eth_signTypedData_v4`. The signature is over the typed data's EIP-712 digest, so it verifies with ethers' `verifyTypedData` (pass `types` without `EIP712Domain`). +- **A Polymarket Safe transaction:** `{"method": "eth_sign", "data": "", "safeTxTypedData": {...}}`. See [Polymarket Safe transactions](#polymarket-safe-transactions). -With `transaction_data`, the EIP-712 digest you computed for it. Optional; if you send it and it doesn't match the typed data, the request returns `400`. +With `transaction_data`, the hash you computed: the EIP-712 digest of `typedData`, or for a Safe transaction the EIP-191 hash of the SafeTx hash. Optional; if you send it and it doesn't match, the request returns `400`. -Signing a bare hash is not supported. A request with `raw_data_hash` and neither `message` nor `transaction_data` returns `400`. `transaction_data` accepts only `eth_signTypedData_v4`. +Signing a bare hash is not supported. A request with `raw_data_hash` and neither `message` nor `transaction_data` returns `400`. `transaction_data` accepts only `eth_signTypedData_v4` typed data and Polymarket Safe transactions. +### Polymarket Safe transactions + +Polymarket's relayer only accepts Safe signatures in the `eth_sign` style: EIP-191 over the 32-byte SafeTx hash. To get one, send the SafeTx hash as `data` and the SafeTx it was computed from as `safeTxTypedData`: + +```json +{ + "raw_data_hash": "", + "transaction_data": { + "method": "eth_sign", + "data": "", + "safeTxTypedData": { + "types": { + "EIP712Domain": [ + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } + ], + "SafeTx": [ + { "name": "to", "type": "address" }, + { "name": "value", "type": "uint256" }, + { "name": "data", "type": "bytes" }, + { "name": "operation", "type": "uint8" }, + { "name": "safeTxGas", "type": "uint256" }, + { "name": "baseGas", "type": "uint256" }, + { "name": "gasPrice", "type": "uint256" }, + { "name": "gasToken", "type": "address" }, + { "name": "refundReceiver", "type": "address" }, + { "name": "nonce", "type": "uint256" } + ] + }, + "primaryType": "SafeTx", + "domain": { "chainId": "137", "verifyingContract": "" }, + "message": { + "to": "", + "value": "0", + "data": "<0x-prefixed calldata>", + "operation": "0", + "safeTxGas": "0", + "baseGas": "0", + "gasPrice": "0", + "gasToken": "0x0000000000000000000000000000000000000000", + "refundReceiver": "0x0000000000000000000000000000000000000000", + "nonce": "" + } + } + } +} +``` + +The SafeTx is checked before anything is signed. The request returns `400` unless: + +- `safeTxTypedData` is a SafeTx with exactly the types above, and `data` is its EIP-712 hash +- `chainId` is `137` and `verifyingContract` is the user's own Polymarket Safe, the one Polymarket's relayer derives from the user's wallet address +- a `delegatecall` (`operation: 1`) goes only to Polymarket's MultiSend, and every transaction batched inside it is a plain call +- no call, top-level or batched, is made to the Safe itself + +The returned `signature` is a plain ECDSA signature over the EIP-191 hash. Before submitting it to the relayer, pack it as Safe expects for `eth_sign` signatures: `r`, `s`, then a `v` of 31 or 32 (add 4 to a `v` of 27 or 28, or 31 to a `v` of 0 or 1). + ### Response Fields