Sale

createSale

Nft owners can launch a sale on an existing marketplace.

Parameter

Request

ArgumentTypeDescription
createSaleParamCreateSaleConfiguration of sale to be created
signerSignerAn instance to represent the wallet account.

CreateSale

ArgumentTypeDescription
contractAddressstringThe address of the nft contract
tokenIdstringThe nftId of the nft under contractAddress
startTimenumberThe start time of the sale
endTimenumberThe end time of the sale
paymentTokenstringThe ERC20 token address that can be used to purchase the nft
pricestringThe price(wei) of the nft for this sale in terms of the paymentToken
tokenTypeTokenTypeAn enum with either 0 or 1 as the value. 0 represents ERC721, while 1 represents ERC1155 contractAddress
amountstringThe amount of nft to be sold.

Response

Here's the provided table formatted in Markdown:

FieldTypeDescription
typenumberThe EIP-2718 type of this transaction.
chainIdnumberThe id of the network.
noncenumberThe nonce used as part of the proof-of-work to mine this block
maxPriorityFeePerGasBigNumberThe price (in wei) per unit of gas for this transaction.
maxFeePerGasBigNumberThe maximum price (in wei) per unit of gas this transaction will pay for (the combined EIP-1559 block's base fee and this transaction's priority fee).
gasPriceBigNumberThe price (in wei) per unit of gas this transaction will pay.
gasLimitBigNumberThe maximum amount of gas that this block was permitted to use.
tostringThe address of the target.
valueBigNumberThe amount (in wei) this transaction is sending.
datastringTransaction data.
accessListAccessListThe AccessList to include; only available for EIP-2930 and EIP-1559 transactions.
hashstringTransaction hash.
vnumberValues for the transaction's signature.
rstringValues for the transaction's signature.
sstringValues for the transaction's signature.
fromstringThe sender address of the transaction.
confirmationsnumberThe number of blocks that have been mined (including the initial block) since this transaction.

Example

// can be native token or any ERC20 token
const paymentToken = <DESIRED_CRYPTO_TOKEN>

// any ERC721 or ERC1155 contract address
const nftAddress = <NFT_ADDRESS>

// any nft token Id under nftAddress
const nftId = <NFT_ID>

const createSaleParam = {
    contractAddress: nftAddress,
    tokenId: nftId,
    startTime: <SALE_START_TIME>,
    endTime: <SALE_END_TIME>,
    paymentToken,
    price: '300',
    tokenType: 1,  // 0 if nftAddress is an ERC721 address, 1 if nftAddress is ERC1155 address
    amount: '2',
};
const result = await marketplaceSdk.createSale(createSaleParam, owner);

editSale

Before the created sale start time, the sale owner can modify the sale properties.

Parameter

Request

ArgumentTypeDescription
saleIdstringThe id of the sale
signerSignerAn instance to represent the wallet account.
startTime (optional)numberThe start time of the sale
endTime (optional)numberThe end time of the sale
paymentToken (optional)stringThe crypto token address that could be used for purchasing the nft in the sale
price (optional)stringThe price(wei) of the nft in terms of paymentToken
amount (optional)stringThe new amount of the nft that needs to be for sale

Response

FieldTypeDescription
typenumberThe EIP-2718 type of this transaction.
chainIdnumberThe id of the network.
noncenumberThe nonce used as part of the proof-of-work to mine this block
maxPriorityFeePerGasBigNumberThe price (in wei) per unit of gas for this transaction.
maxFeePerGasBigNumberThe maximum price (in wei) per unit of gas this transaction will pay for (the combined EIP-1559 block's base fee and this transaction's priority fee).
gasPriceBigNumberThe price (in wei) per unit of gas this transaction will pay.
gasLimitBigNumberThe maximum amount of gas that this block was permitted to use.
tostringThe address of the target.
valueBigNumberThe amount (in wei) this transaction is sending.
datastringTransaction data.
accessListAccessListThe AccessList to include; only available for EIP-2930 and EIP-1559 transactions.
hashstringTransaction hash.
vnumberValues for the transaction's signature.
rstringValues for the transaction's signature.
sstringValues for the transaction's signature.
fromstringThe sender address of the transaction.
confirmationsnumberThe number of blocks that have been mined (including the initial block) since this transaction.

Example

const currTime = Math.floor(Date.now() / 1000);
const startTime = <NEW_SALE_START_TIME>;
const endTime = <NEW_SALE_END_TIME>;
const paymentToken = <DESIRED_CRYPTO_TOKEN>;
const price = '200';
await marketplaceSdk.editSale('1', owner, startTime, endTime, paymentToken, price, '3')

cancelSale

After the nft owner creates a sale, the owner can cancel the sale if the nft has not been sold out.

Parameter

ArgumentTypeDescription
saleIdstringThe id of the existing sale
signerSignerAn instance to represent the wallet account.

Response

FieldTypeDescription
typenumberThe EIP-2718 type of this transaction.
chainIdnumberThe id of the network.
noncenumberThe nonce used as part of the proof-of-work to mine this block
maxPriorityFeePerGasBigNumberThe price (in wei) per unit of gas for this transaction.
maxFeePerGasBigNumberThe maximum price (in wei) per unit of gas this transaction will pay for (the combined EIP-1559 block's base fee and this transaction's priority fee).
gasPriceBigNumberThe price (in wei) per unit of gas this transaction will pay.
gasLimitBigNumberThe maximum amount of gas that this block was permitted to use.
tostringThe address of the target.
valueBigNumberThe amount (in wei) this transaction is sending.
datastringTransaction data.
accessListAccessListThe AccessList to include; only available for EIP-2930 and EIP-1559 transactions.
hashstringTransaction hash.
vnumberValues for the transaction's signature.
rstringValues for the transaction's signature.
sstringValues for the transaction's signature.
fromstringThe sender address of the transaction.
confirmationsnumberThe number of blocks that have been mined (including the initial block) since this transaction.

Example

await marketplaceSdk.cancelSale('1', owner)

buy

After a sale is created, the buyer can buy the nft at the sale.

Parameter

ArgumentTypeDescription
saleIdstringThe id of the sale
purchaseAmountstringThe amount the buyer wants to purchase
paymentTokenstringThe token that is used to pay for the nft by the buyer
paymentAmountstringThe amount to pay in paymentToken , which is supposed to be the product of the nft price and purchaseAmount
signerSignerAn instance to represent the wallet account.

Response

FieldTypeDescription
typenumberThe EIP-2718 type of this transaction.
chainIdnumberThe id of the network.
noncenumberThe nonce used as part of the proof-of-work to mine this block
maxPriorityFeePerGasBigNumberThe price (in wei) per unit of gas for this transaction.
maxFeePerGasBigNumberThe maximum price (in wei) per unit of gas this transaction will pay for (the combined EIP-1559 block's base fee and this transaction's priority fee).
gasPriceBigNumberThe price (in wei) per unit of gas this transaction will pay.
gasLimitBigNumberThe maximum amount of gas that this block was permitted to use.
tostringThe address of the target.
valueBigNumberThe amount (in wei) this transaction is sending.
datastringTransaction data.
accessListAccessListThe AccessList to include; only available for EIP-2930 and EIP-1559 transactions.
hashstringTransaction hash.
vnumberValues for the transaction's signature.
rstringValues for the transaction's signature.
sstringValues for the transaction's signature.
fromstringThe sender address of the transaction.
confirmationsnumberThe number of blocks that have been mined (including the initial block) since this transaction.

Example

await marketplaceSdk.buy('1', paymentToken, '1', buyer)