Nft owners can launch a sale on an existing marketplace.
Request
Argument Type Description createSaleParam CreateSale Configuration of sale to be created signer Signer An instance to represent the wallet account.
CreateSale
Argument Type Description contractAddress string The address of the nft contract tokenId string The nftId of the nft under contractAddress startTime number The start time of the sale endTime number The end time of the sale paymentToken string The ERC20 token address that can be used to purchase the nft price string The price(wei) of the nft for this sale in terms of the paymentToken
tokenType TokenType An enum with either 0 or 1 as the value. 0 represents ERC721, while 1 represents ERC1155 contractAddress amount string The amount of nft to be sold.
Here's the provided table formatted in Markdown:
Field Type Description type number The EIP-2718 type of this transaction. chainId number The id of the network. nonce number The nonce used as part of the proof-of-work to mine this block maxPriorityFeePerGas BigNumber The price (in wei) per unit of gas for this transaction. maxFeePerGas BigNumber The 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). gasPrice BigNumber The price (in wei) per unit of gas this transaction will pay. gasLimit BigNumber The maximum amount of gas that this block was permitted to use. to string The address of the target. value BigNumber The amount (in wei) this transaction is sending. data string Transaction data. accessList AccessList The AccessList to include; only available for EIP-2930 and EIP-1559 transactions. hash string Transaction hash. v number Values for the transaction's signature. r string Values for the transaction's signature. s string Values for the transaction's signature. from string The sender address of the transaction. confirmations number The number of blocks that have been mined (including the initial block) since this transaction.
TypeScript
// 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);
Before the created sale start time, the sale owner can modify the sale properties.
Request
Argument Type Description saleId string The id of the sale signer Signer An instance to represent the wallet account. startTime (optional) number The start time of the sale endTime (optional) number The end time of the sale paymentToken (optional) string The crypto token address that could be used for purchasing the nft in the sale price (optional) string The price(wei) of the nft in terms of paymentToken
amount (optional) string The new amount of the nft that needs to be for sale
Field Type Description type number The EIP-2718 type of this transaction. chainId number The id of the network. nonce number The nonce used as part of the proof-of-work to mine this block maxPriorityFeePerGas BigNumber The price (in wei) per unit of gas for this transaction. maxFeePerGas BigNumber The 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). gasPrice BigNumber The price (in wei) per unit of gas this transaction will pay. gasLimit BigNumber The maximum amount of gas that this block was permitted to use. to string The address of the target. value BigNumber The amount (in wei) this transaction is sending. data string Transaction data. accessList AccessList The AccessList to include; only available for EIP-2930 and EIP-1559 transactions. hash string Transaction hash. v number Values for the transaction's signature. r string Values for the transaction's signature. s string Values for the transaction's signature. from string The sender address of the transaction. confirmations number The number of blocks that have been mined (including the initial block) since this transaction.
TypeScript
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')
After the nft owner
creates a sale, the owner
can cancel the sale if the nft has not been sold out.
Argument Type Description saleId string The id of the existing sale signer Signer An instance to represent the wallet account.
Field Type Description type number The EIP-2718 type of this transaction. chainId number The id of the network. nonce number The nonce used as part of the proof-of-work to mine this block maxPriorityFeePerGas BigNumber The price (in wei) per unit of gas for this transaction. maxFeePerGas BigNumber The 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). gasPrice BigNumber The price (in wei) per unit of gas this transaction will pay. gasLimit BigNumber The maximum amount of gas that this block was permitted to use. to string The address of the target. value BigNumber The amount (in wei) this transaction is sending. data string Transaction data. accessList AccessList The AccessList to include; only available for EIP-2930 and EIP-1559 transactions. hash string Transaction hash. v number Values for the transaction's signature. r string Values for the transaction's signature. s string Values for the transaction's signature. from string The sender address of the transaction. confirmations number The number of blocks that have been mined (including the initial block) since this transaction.
TypeScript
await marketplaceSdk.cancelSale('1', owner)
After a sale is created, the buyer
can buy the nft at the sale.
Argument Type Description saleId string The id of the sale purchaseAmount string The amount the buyer wants to purchase paymentToken string The token that is used to pay for the nft by the buyer paymentAmount string The amount to pay in paymentToken
, which is supposed to be the product of the nft price and purchaseAmount
signer Signer An instance to represent the wallet account.
Field Type Description type number The EIP-2718 type of this transaction. chainId number The id of the network. nonce number The nonce used as part of the proof-of-work to mine this block maxPriorityFeePerGas BigNumber The price (in wei) per unit of gas for this transaction. maxFeePerGas BigNumber The 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). gasPrice BigNumber The price (in wei) per unit of gas this transaction will pay. gasLimit BigNumber The maximum amount of gas that this block was permitted to use. to string The address of the target. value BigNumber The amount (in wei) this transaction is sending. data string Transaction data. accessList AccessList The AccessList to include; only available for EIP-2930 and EIP-1559 transactions. hash string Transaction hash. v number Values for the transaction's signature. r string Values for the transaction's signature. s string Values for the transaction's signature. from string The sender address of the transaction. confirmations number The number of blocks that have been mined (including the initial block) since this transaction.
TypeScript
await marketplaceSdk.buy('1', paymentToken, '1', buyer)