cancelOrder() on the WithdrawQueue contract directly. It covers both direct cancellation (you submit the transaction) and meta-transaction cancellation (a relayer submits on your behalf).
How Cancellations Work
When you submitted a withdrawal order, the WithdrawQueue locked your account shares and minted an ERC-721 NFT to your address representing ownership of the order. To cancel:1
Find your pending orders
Enumerate your order NFTs using the ERC-721 enumerable interface, then
filter by
PENDING status.2
Cancel the order
Call
cancelOrder(orderIndex). The contract verifies you own the order NFT,
then returns your account shares to the refundReceiver address.msg.sender holds the NFT for the given order.
Only orders with
PENDING status (value 1) can be cancelled. Once an order
has been fulfilled or is being processed, it cannot be cancelled.What You’ll Need
ABI Reference
Contract Method Reference
cancelOrder(orderIndex)
cancelOrderWithSignature(orderIndex, deadline, cancelSignature)
For meta-transaction support — a relayer can cancel on behalf of the order owner.
ERC-721 Enumeration (finding your orders)
The WithdrawQueue is an ERC-721 contract. Each withdrawal order is represented by an NFT.Order Statuses
Direct Cancellation Walkthrough
1
Find your order NFTs (read)
Get the number of order NFTs held by your address.If
orderCount is 0, you have no orders to cancel.2
Enumerate and filter pending orders (read)
Loop through your NFTs and check each order’s status.For each Only orders with
i from 0 to orderCount - 1:status == 1 (PENDING) can be cancelled.3
Cancel the order (transaction)
Call The contract:
cancelOrder() for each pending order you want to cancel.- Verifies that
msg.senderowns the order NFT - Returns the locked account shares to the
refundReceiveraddress (set during order submission) - Burns the order NFT
4
Verify cancellation (read, optional)
Confirm the order status changed.Expected:
5 (COMPLETE_REFUNDED)If you already know the
orderIndex (e.g., you saved it from the
OrderSubmitted event when you submitted the withdrawal), you can skip
Steps 1–2 and go directly to cancellation. Just verify the order is still
PENDING first.Meta-Transaction Cancellation
For relayer or gasless cancellation, the order owner signs an EIP-712 message off-chain and anyone can submit the transaction.EIP-712 Type
Walkthrough
1
Build the EIP-712 typed data (off-chain)
EIP-712 Domain:
Cancel message:
2
Sign the typed data (off-chain)
The order owner signs the EIP-712 typed data using their wallet’s
signTypedData method. This produces a 65-byte signature.3
Submit via relayer (transaction)
Anyone can submit the cancellation using the owner’s signature:The contract verifies the signature came from the order NFT owner and that the deadline hasn’t passed.
Troubleshooting
OnlyOrderOwnerCanCancel
OnlyOrderOwnerCanCancel
Your wallet doesn’t own this order’s NFT. Only the original submitter (or
whoever holds the NFT) can cancel.
InvalidOrderType
InvalidOrderType
The order isn’t in
PENDING status. Check getOrderStatus() — only status
1 is cancellable.InvalidOrderIndex
InvalidOrderIndex
The order index doesn’t exist. Verify it from the
OrderSubmitted event or
NFT enumeration.SignatureExpired
SignatureExpired
The deadline in
cancelOrderWithSignature has passed. Generate a fresh
signature with a future deadline.Next Steps
- Direct Deposits — Deposit tokens into an account
- Direct Withdrawals — Submit a withdrawal order
- Account Queries & Monitoring — Read APY, TVL, check balances, and monitor withdrawal status
- SDK Withdrawals Guide — Cancel via the Amplify SDK instead