Skip to main content

Create offers

Marketplace listings actions details

1. Request a Nonce

To sign an offer creation request, you would have to use the same nonce as for the sale creation, the saleNonce, with the below parameters :

Create Nonce Query example :

Request
mutation CreateOfferNonce($userAddress: Address!) {
saleNonce(
user_address: $userAddress
)
}
Params
{
"userAddress": "0x12776a9dab38cc9a164815053737f8b050ffe42f"
}

You will then get a string message in data.saleNonce 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",
};

The below type should be included in your signed request.

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. Create the Offer

Send a createDeal mutation

You would have to use the createDeal mutation with the below DealRequest input object parameter :

  • A kind of type DealKind who will be an offer in our case.

  • An offer parameter of type OfferInput

On Entire Collection

To make an offer on a full collection (any token ID), the offer parameter should have its token_ids fields unset.

Graphql Example

Request

mutation CreateOffer {
createDeal(
input: {
kind: offer
offer: {
token_address: "0x3caf681231bd99df1d2247f41f8e5f02e750fc5e"
buyer: "0x12776a9dab38cc9a164815053737f8b050ffe42f"
unitary_price: "3000000000000000000"
starting_ts: "1666621648"
expiration_ts: "1955885266"
nonce: 42
chain_id: 43113
amount_to_buy: "1"
merkle_root: ""
payment_token: "0x1D308089a2D1Ced3f1Ce36B1FcaF815b07217be3"
buyer_signature: "0x3caf681231bd99df1d2247f41f8e5f02e750fc5e737f8b050ffe42f"
}
}
)
}

On Collection specific Nft(s)

To make an offer on particular collection token ID's :

First, you will have to get a MerkleProof for the aforementioned token IDs by using the tokenIdsProof query.

Graphql Example

Request

query MerkleProof($tokenIDS: [String!]!) {
tokenIdsProof(token_ids: $tokenIDS)
}

Example parameters

{ "tokenIDS": ["0", "42"] }

Then you can build the createDeal request offer parameter with the below fields :

  • The token_ids fields with the selected tokenIds string array

  • The merkle_root field with the string you get on the first step