Order Cancelation
This example demonstrates how to cancel an order on the 21X platform. It involves using the REST client to retrieve the user’s open orders, extracting the orderId
, initializing the OrderBook
class, and canceling the order.
Steps to Cancel an Order
Initialize the REST API Client
Use the REST client to fetch the open orders associated with your wallet.
Fetch Open Orders
Retrieve the list of open orders for your wallet using getWalletOrders
.
Retrieve OrderBook Address
Use the getTradingPair
endpoint to retrieve general information for the selected trading pair.
Initialize the OrderBook
Class
OrderBook
ClassUse the orderbook_address
(of the trading_pair) to initialize the OrderBook
class for smart contract interaction.
Cancel the Order
Use the cancel_buy_order
or cancel_sell_order
method, depending on the type of order you wish to cancel.
Summary of Workflow
Use the REST API client to fetch open orders for your wallet via
getWalletOrders
.Extract the
orderId
and correspondingtrading_pair_id
from the response.Fetch the trading_pair information to get the corresponding
orderbook_address
.Initialize the
OrderBook
class with the retrieved address.Cancel the specified order using the appropriate
OrderBook
method.
Last updated