Skip to main content

Cancel sales and offers

Marketplace listings cancellation actions details

1. Request a cancellation Nonce

To sign a listing cancellation request, you would have to use the cancelNonce mutation with the below parameters :

  • Your user hex address.

  • The listing informations in the request input which include the deal kind and the deal id (uuid v4).

Create Nonce Query example :

Request
mutation CancelSaleNonce($userAddress: Address!, $dealID: String!) {
cancelNonce(
user_address: $userAddress
request: { kind: sale, uuid: $dealID }
)
}
Params
{
"userAddress": "0x12776a9dab38cc9a164815053737f8b050ffe42f",
"dealID": "c10e20e5-cd13-4e03-b14a-ef97eb2adaf8"
}
Example response
{
"data": {
"cancelNonce": "\nYou are requesting to cancel deal id c10e20e5-cd13-4e03-b14a-ef97eb2adaf8 as \naddress 0x12776a9dab38cc9a164815053737f8b050ffe42f owner.\n\nVersion: 1\nChain ID: 43113\nNonce: hzRGmvPZtd\nIssued At: 2022-10-25T10:52:24Z\nExpire At: 2022-10-25T11:02:24Z\n"
}
}

You will then get a string mesage in data.cancelNonce to sign with sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)) using your predefined web3 client implementation (like signer.signMessage for ethers).

2. Sign the message

According to the EIP712 protocol, the data type of the object (in our case, the listing request) to be signed should be always paired with the signing domain informations.

EIP712 Kalao Domain

The domain informations should be represented as an object with the name and version informations like in the javascript example below.

// EIP712 Datas
const domainData = {
name: "Kalao Exchange",
version: "1",
};

Depending on your listing kind, the below types should be included on your signed request.

Sale type
const SaleType = {
Sale: [
{ name: "seller", type: "address" },
{ name: "token_address", type: "address" },
{ name: "token_id", type: "uint256" },
{ name: "in_sale_amount", type: "uint256" },
{ name: "unitary_price", type: "uint256" },
{ name: "expiration_ts", type: "uint256" },
{ name: "starting_ts", type: "uint256" },
{ name: "nonce", type: "uint256" },
{ name: "chain_id", type: "uint256" },
{ name: "managed", type: "bool" },
],
};
Offer type
const OfferType = {
Offer: [
{ name: "buyer", type: "address" },
{ name: "token_address", type: "address" },
{ name: "merkle_root", type: "bytes32" },
{ name: "payment_token", type: "address" },
{ name: "amount_to_buy", type: "uint256" },
{ name: "unitary_price", type: "uint256" },
{ name: "expiration_ts", type: "uint256" },
{ name: "starting_ts", type: "uint256" },
{ name: "nonce", type: "uint256" },
{ name: "chain_id", type: "uint256" },
],
};

With these informations, you will have to call the _signTypedData for ethers.js or equivalent for other clients.

Javascript with ethers signer sale listing example :

// EIP712 Signature creation
let signature = await signer._signTypedData(domainData, SaleType, {
seller: nsale.seller,
token_address: nsale.token_address,
token_id: nsale.token_id,
in_sale_amount: nsale.in_sale_amount,
unitary_price: nsale.unitary_price,
expiration_ts: nsale.expiration_ts,
starting_ts: nsale.starting_ts,
nonce: nsale.nonce,
chain_id: nsale.chain_id,
managed: nsale.managed,
});

3. Send a CancelDeal mutation

Then, you will have to use the CancelDeal mutation with the following parameters :

  • The targetted listing type and id with input parameter
  • The nonce received in part 1 withcancel_nonce parameter
  • Your signature in hex format with cancel_signature parameter
  • And your user_address

Graphql Example

Request

mutation CancelSale(
$saleId: String!
$userAddress: Address!
$nonce: String!
$signature: String!
) {
cancelDeal(
input: { kind: sale, uuid: $saleId }
cancel_nonce: $nonce
user_address: $userAddress
cancel_signature: $signature
) {
infos
complete
sale_ticket {
seller
token_address
token_id
in_sale_amount
unitary_price
expiration_ts
starting_ts
nonce
chain_id
min_unitary_price
managed
seller_signature
validator_signature
sale_id
}
}
}

Example Parameters

{
"saleId": "c10e20e5-cd13-4e03-b14a-ef97eb2adaf8",
"signature": "0x12776a9dab38cc9a164815053737f8b050ffe42fef97eb2adaf8",
"nonce": "\nYou are requesting to cancel deal id c10e20e5-cd13-4e03-b14a-ef97eb2adaf8 as \naddress 0x12776a9dab38cc9a164815053737f8b050ffe42f owner.\n\nVersion: 1\nChain ID: 43113\nNonce: YZmHuFnjNb\nIssued At: 2022-10-24T15:54:30Z\nExpire At: 2022-10-24T16:04:30Z\n",
"userAddress": "0x12776a9dab38cc9a164815053737f8b050ffe42f"
}