One of the key features is the ability to accept bids on NFTs. This article will guide you through the process of accepting a bid using the Rarible SDK.
Prerequisite
Follow our Getting started guide to install needed libraries and instantiate SDK.
Accepting bid
- Connect Wallet: Ensure the user's wallet is connected. This can be done using wallet connect protocols.
- Find an NFT which you have and there is a bid which can be accepted. Best (highest) bid is in the field bestBidOrder in Item
- Accept this bid using SDK
// Fetch NFT which has bid
const item = await sdk.apis.item.getItemById({ itemId: "ETHEREUM:X:Y" })
const tx = await sdk.order.acceptBid({
orderId: item.bestBidOrder.id,
amount: 1, //for multiple NFTs you can provide
})
- Confirm approval transaction and confirm "Accept bid" transaction using your wallet
- Verify bid was accepted:
- NFT is transferred to the buyer
- You got the money
Conclusion
Accepting a bid on an NFT using the Rarible SDK is a straightforward process. By following these steps, you can seamlessly integrate bid acceptance functionality into your application. For more advanced use cases and additional features, refer to the Rarible SDK documentation.