To cancel an order(s) on X2Y2, follow the steps below.

Generate user signed message

Only order's maker could cancel the order. To verify the current user's address, two messages are necessary to be posted to X2Y2 server.

// Generate a Keccak256 hash of any string
const signMessage = ethers.utils.keccak256('0x')

// Ask user's wallet to sign the message
const sign = (await web3Provider.send('personal_sign', [
  ])) as string

Get input for order cancel

Call the Sign cancel order to get the necessary input to be submitted via wallet.

const cancelResponse = await post('', JSON.stringify({
    caller: userAddress,
    op: 3,
    items: [{
    sign_message: signMessage,
}), {
    headers: {
        'Content-Type': 'application/json; charset=utf-8',
        'X-API-KEY': X2Y2_API_KEY,
// Extract cancel input from cancelResponse…

Decode the input data

const inputData = ethers.utils.defaultAbiCoder.decode(
    [`tuple(bytes32[] itemHashes, uint256 deadline, uint8 v, bytes32 r, bytes32 s)`],

const cancelInput = [inputData.itemHashes, inputData.deadline, inputData.v, inputData.r, inputData.s] as const

Submit the data to user's wallet

Submit the cancelInput decoded to buyer's wallet to finish the cancellation.

const marketContract = '0x74312363e45DCaBA76c59ec49a7Aa8A65a67EeD3' // X2Y2's market address on Mainnet. Use 0x1891EcD5F7b1E751151d857265D6e6D08ae8989e for Goerli testnet
const abi = [] // JSON format of X2Y2's market contract ABI, available at ``
const market = new ethers.Contract(marketContract, abi, web3Provider)
const tx = await market.cancel(cancelInput)