Skip to content
Finality

Crypto protocol and market news

How Does Pre-Signing Work for Smart Contract Wallet Orders?

How presign works for smart contract wallet orders: post the order off-chain, then authorize its exact order UID on-chain with setPreSignature before solvers can trade it.

The Finality Desk4 min read#7eb7e4

How Does Pre-Signing Work for Smart Contract Wallet Orders?

Smart contract wallet orders on CoW Swap use pre-signing when the wallet must authorize an order on-chain: post it with the presign signing scheme, then have the wallet call setPreSignature for its order UID. The order becomes open after that transaction confirms.

  • You’ll see how the order moves from pending to open, and what can make authorization revert.
  • You’ll need the order UID and an on-chain transaction from the owner address.

What does posting a presign order send to the API?

Posting a presign order sends its order parameters and the owner address as the signature. The API stores the order as presignaturePending and returns an order UID. The order is not yet eligible for solvers.

That UID identifies the specific order. It is 56 bytes: a 32-byte order digest, a 20-byte owner address, and a 4-byte validTo value. The digest represents the order parameters. The owner field identifies the wallet that must authorize it.

This is a different authorization path from asking a wallet to provide an EIP-1271 signature for validation. With presigning, the submitted owner address identifies the order’s owner; the later on-chain call supplies the authorization. It does not turn the address into an ECDSA signature.

How does setPreSignature make the order live?

The owner calls GPv2Settlement.setPreSignature(orderUid, true) from the address encoded in that UID. The call writes the pre-signature authorization for that exact UID to the settlement contract. It costs gas, and the order remains presignaturePending until the transaction confirms.

After confirmation, the API can move the order to open, making it eligible for solvers in CoW Swap’s batch auctions. For a Safe, the Safe itself must be the owner in the UID and the caller seen by the settlement contract. A Safe owner’s externally owned account cannot substitute for the Safe address by calling the function directly.

For an integration, keep the returned UID with the pending order and submit that same value in the authorization call. A gasless swap cowswap can be useful context when explaining the trading flow, but this authorization step is a separate on-chain transaction.

Why does changing an order require a new pre-sign?

The pre-signature is bound to the complete order UID, so changing an order field produces a different digest and UID. That includes changing the amount, validTo, or receiver. The authorization stored for the old UID does not authorize the edited order.

Take a Safe that posts an order to sell 10 units of one token for a specified amount of another, with a particular receiver and expiry. The API returns UID A. The Safe calls setPreSignature(UID A, true); once confirmed, that order can become open. If the integration changes the receiver or expiry before authorization, the revised order has UID B. The Safe must authorize UID B in a new transaction.

This matters when an application rebuilds an order after a user has reviewed it. Keep the submitted order parameters and returned UID together. After any edit, post the revised order and use its newly returned UID. Do not reuse an earlier authorization just because the owner and the broad trade intent are unchanged.

What makes authorization revert, and how can the owner cancel?

setPreSignature reverts unless msg.sender is the owner encoded in the UID. For a Safe-owned order, the Safe must execute the call so that the settlement contract sees the Safe as the caller. A call sent directly from an individual Safe owner’s address fails this check.

To cancel the on-chain pre-signature, the owner calls setPreSignature(orderUid, false) for that same UID. This revokes authorization for that order. The call must come from the encoded owner, and the change takes effect when the transaction confirms. Handle the order and its UID as a pair in application state so the cancellation targets the authorization that was actually granted.

The lifecycle is therefore: post with signingScheme set to presign, retain the returned UID, authorize it from the owner address, then treat the order as open after confirmation. A failed owner check leaves the on-chain authorization unset; a changed order needs its own UID and authorization; and cancellation revokes the pre-signature for the selected UID.