Import

Usage
TheuseSellModal
hook provides a convenient way to manage the sell modal interface for accepting offers on collectibles. This modal is specifically used when a user wants to sell their collectible to an existing offer (bid) on the marketplace.
Make sure you have followed the Getting
Started guide
to get the collection address and chainId.
Basic Example
This example uses the
useBalanceOfCollectible
hook from marketplace-sdk to verify ownership before showing the sell modal.Parameters
The hook accepts an optionalcallbacks
object with the following properties:
Parameter | Type | Description |
---|---|---|
callbacks.onSuccess | ({ hash, orderId }: { hash?: Hash; orderId?: string }) => void | Optional callback function called when the sale is completed successfully |
callbacks.onError | (error: Error) => void | Optional callback function called when an error occurs during the sale |
callbacks.successActionButtons | Array<{ label: string; action: () => void }> | Optional array of action buttons to show on success |
Return Type
The hook returns an object with the following methods:Methods
show
(args: ShowSellModalArgs) => void
Opens the sell modal with the specified parameters to accept an offer.
Parameter | Type | Required | Description |
---|---|---|---|
collectionAddress | Address | Yes | The contract address of the collection |
chainId | number | Yes | The blockchain network ID (e.g., 1 for Ethereum, 137 for Polygon) |
tokenId | string | Yes | The collectible ID of the collectible being sold |
order | Order | Yes | The offer order object containing price, buyer, and other details |
close
() => void
Closes the sell modal.
Notes
TheuseSellModal
hook provides a convenient way to manage the sell modal interface for accepting offers on collectibles. It handles:
- Opening and closing the modal
- Managing the sale transaction flow state
- Token approval steps (if required)
- Transaction execution and signature steps
- Error handling and success callbacks
- Support for different marketplace types
- Integration with WaaS (Wallet as a Service) fee options
Prerequisites
Before using this hook, ensure:- User Authentication: The user must be connected with a wallet
- Ownership Verification: Use hooks like
useBalanceOfCollectible
to verify the user owns the collectible - Valid Offer: Ensure there’s a valid offer (Order object) to accept
Related Hooks
useBalanceOfCollectible
- Check ownershipuseListOffersForCollectible
- Get available offers