Cancel a listed NFT

This guide is a continuation of the Listing example.

As a maker, you can always cancel a listing (or any other order) - the Acilia NFT Swap API makes this trivial.

Any order created from the Acilia NFT Swap API can be filled or cancelled without the need to the same API. The orders generated by this API are simple 0x orders and can be cancelled by interacting with the smart contracts directly or with Trader SDK libraries.

Step 1: Request cancellation call-data

Pass in the AciliaID from the previous Listing request

payload = json.dumps({
  "aciliaId": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcm..."
})
headers = {
  'Authorization': f'Bearer {api_token}',
  'Content-Type': 'application/json'
}

response = requests.request(
  "POST",
  f"https://{acilia_api_domain}/v1/order/cancel",
  headers=headers,
  data=payload
)

response = response.json()

Below is the sample response coming from the API 👇 - which will contain the following

  • order contains the deserialized order

  • cancelOrderTransaction is an Ethereum transaction that can be used to cancel that order. The order must be send by the maker, of course.

You are always encouraged to review call-data before before you submit it on-chain.

{
  "aciliaId": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXV...",
  "order": {
    "erc721Token": "0x26970ceb166b71db3480b7464387f793a570259a",
    "erc721TokenId": "2",
    "direction": "SELL",
    "erc20Token": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
    "erc20TokenAmount": "20000000000000000000",
    "maker": "0x26970ceb166b71db3480b7464387f793a570259a",
    "erc721TokenProperties": [],
    "fees": [],
    "expiry": "1846785190",
    "nonce": "100131415900000000000000000000000000000275088661344072499795790248876436988724",
    "taker": "0x0000000000000000000000000000000000000000",
    "chain": "POLYGON"
  },
  "cancelOrderTransaction": {
    "from": "0x26970ceb166b71db3480b7464387f793a570259a",
    "to": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF",
    "value": "0",
    "data": "0xbe167b9ddd605f7d554cc445cede96d76a0..."
  }
}

Step 2: Cancel the order on-chain

# Using the same `send_transaction` code in the previous examples.
# This example assumes that Bob's address is 0x26970ceb166b71db3480b7464387f793a570259a
send_transaction(operation['transaction'], BOB_PK)

Step 3: Ensure the transaction succeeds

Ensure the transaction is correctly mined - and check the transaction logs to ensure the cancellation is successful.

Last updated