Skip to main content

Offers

Functionality available for contracts that implement the IOffers interface.

acceptOffer

Accept an offer placed on your NFT.

const txResult = await contract.offers.acceptOffer("{{offer_id}}");
Configuration

offerId

The ID of the offer to accept.

You can view all offers with getAll or getAllValid.

Must be a string, number, or BigNumber.

cancelOffer

Cancel an offer you made on an NFT.

const txResult = await contract.offers.cancelOffer("{{offer_id}}");
Configuration

offerId

The ID of the offer to cancel.

You can view all offers with getAll or getAllValid.

Must be a string, number, or BigNumber.

getAll

Get all offers on the smart contract.

Optionally, provide a filter to filter the offers returned.

const offers = await contract.offers.getAll();
Configuration

filter (optional)

Filter the results returned by the function.

const offers = await contract.offers.getAll({
offeror: "{{wallet_address}}", // Offers made by this wallet address
seller: "{{wallet_address}}", // Offers on items being sold by this wallet address
tokenContract: "{{contract_address}}", // Offers on items from this contract
tokenId: "{{token_id}}", // Offers on this specific token
start: 0, // Pagination: Start from this index
count: 100, // Pagination: Return this many results
});

Return Value

Returns an array of OfferV3 objects, containing the following properties:

{
id: string; // The id of the offer.
offerorAddress: string; // The wallet address of the creator of offer.
assetContractAddress: string; // The address of the asset being offered on.
tokenId: string; // The ID of the token.
quantity: string; // The quantity of tokens offered to buy
currencyContractAddress: string; // The address of the currency offered for the NFTs.
currencyValue: CurrencyValue; // The `CurrencyValue` of the offer. Useful for displaying the price information.
totalPrice: string; // The total offer amount for the NFTs.
asset: NFTMetadata; // Metadata of the asset
endTimeInSeconds: number; // The end time of the offer.
status: Status; // Whether the listing is CREATED, COMPLETED, or CANCELLED.
}
[];

getAllValid

Get all the valid offers on the smart contract.

Valid offers are offers that have not expired, been canceled, or been accepted.

const offers = await contract.offers.getAllValid();
Configuration

filter (optional)

Filter the results returned by the function.

const offers = await contract.offers.getAllValid({
offeror: "{{wallet_address}}", // Offers made by this wallet address
seller: "{{wallet_address}}", // Offers on items being sold by this wallet address
tokenContract: "{{contract_address}}", // Offers on items from this contract
tokenId: "{{token_id}}", // Offers on this specific token
start: 0, // Pagination: Start from this index
count: 100, // Pagination: Return this many results
});

Return Value

Returns an array of OfferV3 objects, containing the following properties:

{
id: string; // The id of the offer.
offerorAddress: string; // The wallet address of the creator of offer.
assetContractAddress: string; // The address of the asset being offered on.
tokenId: string; // The ID of the token.
quantity: string; // The quantity of tokens offered to buy
currencyContractAddress: string; // The address of the currency offered for the NFTs.
currencyValue: CurrencyValue; // The `CurrencyValue` of the offer. Useful for displaying the price information.
totalPrice: string; // The total offer amount for the NFTs.
asset: NFTMetadata; // Metadata of the asset
endTimeInSeconds: number; // The end time of the offer.
status: Status; // Whether the listing is CREATED, COMPLETED, or CANCELLED.
}
[];

getOffer

Get information about a specific offer using the offers ID.

const offer = await contract.offers.getOffer("{{offer_id}}");
Configuration

offerId

The ID of the offer to get information about.

You can view all offers with getAll or getAllValid.

Return Value

Returns a single OfferV3 object containing the following properties:

{
id: string; // The id of the offer.
offerorAddress: string; // The wallet address of the creator of offer.
assetContractAddress: string; // The address of the asset being offered on.
tokenId: string; // The ID of the token.
quantity: string; // The quantity of tokens offered to buy
currencyContractAddress: string; // The address of the currency offered for the NFTs.
currencyValue: CurrencyValue; // The `CurrencyValue` of the offer. Useful for displaying the price information.
totalPrice: string; // The total offer amount for the NFTs.
asset: NFTMetadata; // Metadata of the asset
endTimeInSeconds: number; // The end time of the offer.
status: Status; // Whether the listing is CREATED, COMPLETED, or CANCELLED.
}

getTotalCount

Get the total number of offers on the smart contract

const numOffers = await contract.offers.getTotalCount();
Configuration

Return Value

Returns a BigNumber representing the total number of offers on the smart contract.

BigNumber;

makeOffer

Make a new offer on an NFT.

Offers can be made on any NFT, regardless of whether it is listed for sale or not.

const txResult = await contract?.offers.makeOffer({
assetContractAddress: "{{contract_address}}", // Required - the contract address of the NFT to offer on
tokenId: "{{token_id}}", // Required - the token ID to offer on
totalPrice: "{{offer_price}}", // Required - the price to offer in the currency specified
currencyContractAddress: "{{contract_address}}", // Optional - defaults to the native wrapped currency
endTimestamp: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 10), // Optional - Defaults to 10 years from now
quantity: 1, // Optional - defaults to 1
});
Configuration

assetContractAddress

The smart contract address of the NFT to make an offer on.

Required. Must be a string.

tokenId

The token ID of the NFT to make an offer on.

Required. Must be a string, number, or BigNumber.

totalPrice

The price to offer.

Required. Must be a string or a number.

currencyContractAddress

The smart contract address of the currency to offer in.

Optional. Defaults to the native wrapped currency. e.g. Wrapped Ether for Ethereum, or wMatic for Polygon.

Must be a string.

endTimestamp

The timestamp at which the offer will expire.

Optional. Defaults to 10 years from now.

Must be a Date object.

quantity

The quantity of NFTs you are offering to buy.

This is relevant for ERC1155 NFTs where you can buy multiple tokens at once.

Optional. Defaults to 1.

Must be a string, number, or BigNumber.