Order Canceler ABI
The Order Canceler is a separate contract for cancelling orders. Orders are identified by their NFT token ID.
Address (Sepolia): 0x53ad1ffcd7afb1b14c5f18be8f256606efb11b1b
Functions
[
{
"name": "cancel",
"type": "function",
"stateMutability": "nonpayable",
"inputs": [
{
"name": "paramsList",
"type": "tuple[]",
"components": [
{ "name": "market", "type": "address" },
{ "name": "tokenIds", "type": "uint256[]" }
]
}
],
"outputs": []
},
{
"name": "cancelTo",
"type": "function",
"stateMutability": "nonpayable",
"inputs": [
{
"name": "paramsList",
"type": "tuple[]",
"components": [
{ "name": "market", "type": "address" },
{ "name": "tokenIds", "type": "uint256[]" }
]
},
{ "name": "to", "type": "address" }
],
"outputs": []
}
]
Use cancel to receive tokens back to your own address, or cancelTo to send them to a different address.
Function Reference
cancel
Cancels orders and returns tokens to the caller’s address.
| Parameter | Type | Description |
|---|
paramsList | CancelParams[] | Array of cancel parameters |
CancelParams:
| Field | Type | Description |
|---|
market | address | The market (OrderBook) contract address |
tokenIds | uint256[] | Array of Order NFT token IDs to cancel |
cancelTo
Cancels orders and sends returned tokens to a specified address.
| Parameter | Type | Description |
|---|
paramsList | CancelParams[] | Array of cancel parameters |
to | address | Recipient address for the returned tokens |
Usage Example
import { ethers } from 'ethers';
const CANCELER_ABI = [
{
"name": "cancel",
"type": "function",
"stateMutability": "nonpayable",
"inputs": [{
"name": "paramsList",
"type": "tuple[]",
"components": [
{ "name": "market", "type": "address" },
{ "name": "tokenIds", "type": "uint256[]" }
]
}],
"outputs": []
},
{
"name": "cancelTo",
"type": "function",
"stateMutability": "nonpayable",
"inputs": [
{
"name": "paramsList",
"type": "tuple[]",
"components": [
{ "name": "market", "type": "address" },
{ "name": "tokenIds", "type": "uint256[]" }
]
},
{ "name": "to", "type": "address" }
],
"outputs": []
}
];
const CANCELER_ADDRESS = '0x53ad1ffcd7afb1b14c5f18be8f256606efb11b1b';
const provider = new ethers.JsonRpcProvider('https://0xrpc.io/sep');
const signer = new ethers.Wallet(PRIVATE_KEY, provider);
const canceler = new ethers.Contract(CANCELER_ADDRESS, CANCELER_ABI, signer);
// Cancel orders from a single market
const cancelParams = [{
market: '0x2e4a11c7711c6a69ac973cbc40a9b16d14f9aa7e', // EURC/XSGD market
tokenIds: [123n, 456n, 789n] // Your order NFT IDs
}];
const tx = await canceler.cancel(cancelParams);
await tx.wait();
console.log('Orders cancelled successfully');
Cancel Orders from Multiple Markets
// Cancel orders across multiple markets in one transaction
const cancelParams = [
{
market: '0x2e4a11c7711c6a69ac973cbc40a9b16d14f9aa7e', // EURC/XSGD
tokenIds: [123n, 456n]
},
{
market: '0x1234567890abcdef1234567890abcdef12345678', // Another market
tokenIds: [789n, 1011n, 1213n]
}
];
const tx = await canceler.cancel(cancelParams);
await tx.wait();
Getting Order NFT IDs
When you place a limit order, you receive an Order NFT. Find your order NFT IDs via the GraphQL API:
query MyOrders($user: String!) {
openOrders(
where: { user: $user }
orderBy: createdAt
orderDirection: desc
) {
nftId # This is the tokenId for cancellation
market
isBid
price
rawOpenAmount
}
}
See the Orders Query for more details on querying your orders.