Skip to main content
After creating listings or reviewing filled orders, you may need to cancel them. Learn how to cancel NFT orders using both soft (gasless) and hard (on-chain) cancellation methods.
See Getting Started for prerequisites and installation. For cancellation, you also need the Order ID(s) and must own the orders.

Trade Execution Architecture

Immutable offers a centralized orderbook but doesn’t act as an intermediary during trades. Instead, trades settle through a smart contract, ensuring secure peer-to-peer trading. To understand cancellation, first understand how trades execute:

5-Step Trade Flow

  1. Buyer selects order - User chooses a listing via marketplace
  2. Orderbook prepares payload - Immutable generates transaction details for settlement contract
  3. Buyer signs transaction - User reviews and signs
  4. Transaction submitted - Signed transaction sent to settlement contract
  5. Settlement executes - Contract swaps assets if all details valid
This creates two cancellation opportunities:
Why Two Methods?
  • Soft cancel prevents the orderbook from providing transaction details (Step 2). Gasless but has race condition.
  • Hard cancel blacklists the order in the settlement contract (Step 5). Costs gas but is definitive—even if someone has a signed transaction, it will fail.
For complete order status progression, see the Order Lifecycle documentation.

Soft Cancel (Gasless)

Soft cancellation is free and instant—the order is marked as cancelled off-chain, preventing new fulfillments.

How It Works

  1. User signs a message proving they own the order (EIP-712)
  2. Orderbook marks order as cancelled
  3. Orderbook stops generating transaction details for this order
  4. Order becomes unfillable by new buyers

Basic Example

Response Structure

The response categorizes cancellations into three arrays:
Understanding pending_cancellationsOrders in pending_cancellations have an active transaction payload already issued to a buyer. These orders may still execute even though your cancel was accepted by the orderbook.This happens when:
  1. Buyer started fulfillment process before your cancel
  2. Buyer received transaction details (Step 2) before cancel
  3. Buyer has 90 seconds to submit the signed transaction
If you see orders in pending_cancellations, consider using a hard cancel for guaranteed cancellation.

The 90-Second Race Condition

Critical: Race Condition WindowThe execution window is 90 seconds from when the orderbook provides transaction details (Step 2), NOT from when you initiated the cancel.Timeline:
During the 90-second window, your asset may still be exchanged at the previously agreed price if the buyer submits their signed transaction.The race condition exists for LESS than 90 seconds from when the cancel was accepted—but you don’t control when the buyer started Step 2.

Validating Soft Cancel

Poll the order to confirm status transitions to CANCELLED:

Limits

Batch Limits: You can cancel up to 20 orders in a single soft cancel transaction. For more than 20, batch them into multiple requests.

Hard Cancel (On-Chain)

Hard cancellation provides definitive cancellation by updating the settlement contract’s blacklist. Costs gas but eliminates race conditions.

How It Works

  1. User sends transaction to settlement contract
  2. Contract adds order to blacklist
  3. Any future fulfillment attempts for this order will fail on-chain
  4. Even if someone has a signed transaction, contract rejects it

When to Use Hard Cancel

Basic Example

Response

Hard cancel returns transaction details:

Validating Hard Cancel

Poll the order after transaction confirms:
Async Status Updates: After the transaction confirms, Immutable services must detect the on-chain event and update the off-chain orderbook. This usually takes a few seconds but can take longer during network congestion.

Complete Cancellation Flow

Full example with error handling and user choice:

Decision Matrix: Soft vs Hard

Choose the right cancellation method based on your scenario:

Error Handling

Common errors during cancellation:

Best Practices

  1. Check pending_cancellations: Warn users about race conditions
  2. Show gas estimates: For hard cancels, display gas cost before execution
  3. Poll for status: Don’t assume immediate cancellation
  4. Batch cancels: Group multiple soft cancels into one request (max 20)
  5. Upgrade path: Offer hard cancel if soft cancel returns pending
  6. Expiration check: If order expires soon, soft cancel sufficient
  7. Value-based logic: Use hard cancel for high-value orders automatically

Understanding Gas

What is Gas?Gas is the computational fee required to perform blockchain transactions. It serves two purposes:
  1. Incentivize Validators: Pays network validators to include your transaction
  2. Prevent Spam: Makes it costly to abuse the network
Who Pays Gas in Orderbook:
  • Creating orders: Free for both buyers and sellers (gasless signatures)
  • Filling orders: Buyers pay gas to execute the trade
  • Canceling orders:
    • Soft cancel: Free (gasless)
    • Hard cancel: Sellers pay gas for on-chain cancellation
This is why soft cancels are recommended for casual users—they preserve the gasless experience.

Next Steps

Create Listings

Learn how to create NFT listings

Fill Orders

Buy NFTs by filling orders

Order Management

Query and manage order status

Bulk Operations

Cancel multiple orders efficiently

Fees

Understand gas costs for hard cancels