Skip to main content

Authentication

All endpoints require the following headers unless otherwise noted:
string
required
Bearer token (JWT) for end-user authentication. Format: Bearer YOUR_JWT_TOKEN
string
required
Your Magic secret key for application-level authentication.

Sign Data

Sign data with the authenticated user’s Magic wallet.
cURL
To sign EIP-712 typed data, send it as transaction_data instead of message:
cURL
Response:

Request Parameters

Provide either message or transaction_data.
string
A plain text message to sign. It is signed as an EIP-191 (personal_sign) message over its UTF-8 bytes, so you can verify it with standard tools such as ethers’ verifyMessage.
object
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": "<SafeTx hash>", "safeTxTypedData": {...}}. See Polymarket Safe transactions.
string
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 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:
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

boolean
Whether the signing operation completed successfully.
string
The hex-encoded signature.
string
The hash that was signed: the EIP-191 hash of message, or the EIP-712 digest of transaction_data.typedData.
string
The user identifier from your application.

Withdraw to External Address

Send funds from the authenticated user’s Magic wallet to an external address.
cURL
Response: message is generated by the server (success text includes amount, token, and chain, and notes EIP-7702 gas-sponsored sends when applicable). tx_hash is an EVM transaction hash (0x…) or a Solana signature string depending on chain.

Request Parameters

string
required
The recipient wallet address. EVM destinations are normalized to checksummed hex; Solana addresses are validated as base58.
string
required
The amount to withdraw as a decimal string.
string
default:"USDC"
The token to withdraw. Values: ETH, USDC, USDC.E, POL, SOL
string
default:"ARB"
The chain to withdraw on. Values: ETH, ARB, POL, SOL, INK
boolean
default:"false"
Request gas-sponsored execution for EVM withdrawals when supported (Alchemy EIP-7702 path). Ignored for Solana (should_sponsor_gas is false on SOL).

Supported Token/Chain Combinations

Response Fields

boolean
Whether the withdrawal was executed successfully.
string
The on-chain transaction identifier (EVM: 0x tx hash; Solana: base58 signature).
string
The sender’s wallet address.
string
The recipient’s wallet address after server-side normalization.
string
The amount withdrawn.
string
The token that was withdrawn.
string
The chain the withdrawal was executed on.
string
Human-readable status message describing the completed withdrawal.