Purchase a listed NFT

This guide is a continuation of the Listing example.

Once an NFT is listed, it can be purchased by a taker. Acilia's API helps generate the call-data that the taker can use to perform the swap.

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

Step 1: Request fill call-data

Pass in the AciliaID from the previous Listing request, alongside the taker that will be used to fill this order.

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

response = requests.request(
  "POST",
  f"https://{acilia_api_domain}/v1/order/fill",
  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

  • fillOrderTransaction is an Ethereum transaction that can be used to fill that order. The order must be send by the taker.

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"
  },
  "fillOrderTransaction": {
    "from": "0x26970ceb166b71db3480b7464387f793a570259a",
    "to": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF",
    "value": "20000000000000000000",
    "data": "0xfbee349d0000000000000000000000000000000000..."
  }
}

Step 2: Fill the order on-chain

# Using the same `send_transaction` code in the previous examples.
send_transaction(operation['transaction'], ALICE_PK)

Step 3: Ensure the transaction succeeds

Ensure the transaction is correctly mined - and check the transaction logs to ensure the fill of the order is successful.

Last updated