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
- Buyer selects order - User chooses a listing via marketplace
- Orderbook prepares payload - Immutable generates transaction details for settlement contract
- Buyer signs transaction - User reviews and signs
- Transaction submitted - Signed transaction sent to settlement contract
- Settlement executes - Contract swaps assets if all details valid
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.
Soft Cancel (Gasless)
Soft cancellation is free and instant—the order is marked as cancelled off-chain, preventing newfulfillments.
How It Works
- User signs a message proving they own the order (EIP-712)
- Orderbook marks order as cancelled
- Orderbook stops generating transaction details for this order
- Order becomes unfillable by new buyers
Basic Example
Response Structure
The response categorizes cancellations into three arrays:The 90-Second Race Condition
Validating Soft Cancel
Poll the order to confirm status transitions toCANCELLED:
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
- User sends transaction to settlement contract
- Contract adds order to blacklist
- Any future fulfillment attempts for this order will fail on-chain
- 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
- Check
pending_cancellations: Warn users about race conditions - Show gas estimates: For hard cancels, display gas cost before execution
- Poll for status: Don’t assume immediate cancellation
- Batch cancels: Group multiple soft cancels into one request (max 20)
- Upgrade path: Offer hard cancel if soft cancel returns pending
- Expiration check: If order expires soon, soft cancel sufficient
- 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:
- Incentivize
Validators: Pays networkvalidatorsto include your transaction - Prevent Spam: Makes it costly to abuse the network
- 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
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