Skip to main content

The rule

No single key can move user funds on PredictStreet. Vault.withdrawERC20 on-chain checks two signatures:
  1. User signature — EIP-712 from the vault owner EOA.
  2. Backend signature — EIP-712 from a platform backend key: any address holding BACKEND_ROLE on the VaultFactory (VaultFactory.isBackend(signer)).
Both must cover the exact same typed-data struct. The contract also verifies that the backend signer and vault owner are distinct keys (OwnerAndBackendSignerMustDiffer); a vault owner who holds BACKEND_ROLE cannot collapse the dual signature into one. If either signature is missing, invalid, or replayed, the vault reverts. msg.sender of the tx is unconstrained — a relayer, the user, or a third party can submit.

Sequence

Why two signatures

  • User signature. Proves user authorised this specific withdrawal.
  • Backend signature. Attests the request passed platform compliance (AML, banned-destination, restrictions).
  • Unilateral backend moves are impossible. The backend’s key alone doesn’t unlock the vault.

What the on-chain verifies

Simplified, in check order:
Key invariants:
  • Digest-based replay protection — single-use per digest (usedDigests[digest]).
  • Revocable before execution — the vault owner or a platform backend key can call invalidateDigest(digest) (or the batch invalidateDigests) to burn a signed withdrawal before it is submitted; any later submission of that digest reverts. See Digest invalidation.
  • Emergency withdraw — if the backend is gone or refusing legitimate withdrawals, the vault owner calls initiateEmergencyWithdraw(); after a 7-day timelock (EMERGENCY_TIMELOCK), it can drain the vault (balanceOf, including off-ledger surplus) to the owner address during a 7-day window (EMERGENCY_EXECUTION_WINDOW), with no backend signature. Executing an emergency drain freezes the owner’s limits in DepositLimitRegistry and permanently disables trading settlement on that vault (tradingDisabledAfterEmergency = true). See Emergency withdraw.
  • Expired reservations & automatic recovery — if a withdrawal’s deadline passes before execution, the vault contract rejects late submissions (WithdrawExpired). Unlike splits/merges (which feature a manual POST /api/me/splits-merges/{opId}/unlock endpoint), withdrawals have no user-facing unlock endpoint. Instead, the platform’s backend chain-watcher automatically verifies that the on-chain digest is unconsumed, transitions the row to EXPIRED, and refunds the locked balance (locked -> available). Users can also cancel in-flight withdrawals before submission via POST /api/me/withdrawals/{id}/cancel.

Backend co-signer security

The backend co-signing keys are the addresses holding BACKEND_ROLE on the VaultFactory. More than one can be active at a time, and any of them can be revoked on-chain via revokeRole. The vault checks isBackend when the withdrawal executes, so a signature from a revoked key no longer verifies.

Relay submission & gas limit headroom (v2.9.37)

The backend relay submits the co-signed withdrawERC20 transaction. The transaction gas limit is dynamically padded above the raw RPC estimate:
This headroom guarantees that if the recipient wallet’s token balance transitions from zero to non-zero between estimation and block inclusion (which adds up to ~17.3k gas for ERC-20 state storage), the transaction does not revert with SafeERC20: low-level call failed. Unused gas is refunded automatically.