Import
Usage
Data Hooks
The SDK provides specialized hooks to fetch and format data for the CollectibleCard component:Market Cards
Shop Cards
For shop cards, there are two hooks based on the contract type:- Data fetching and formatting
- Loading states
- Pagination (for market cards)
- Type-specific data requirements
- Integration with filters and search
Examples
Example of using the CollectibleCard component in a marketplace context:
Parameters
The component accepts different props based on the marketplace type:Base Props
These properties are shared by all card types:Parameter | Type | Description |
---|---|---|
collectibleId | string | Unique identifier for the collectible |
chainId | number | The blockchain network ID |
collectionAddress | Address | The smart contract address of the collection |
collectionType | ContractType | Optional. The type of contract (ERC721 or ERC1155) |
assetSrcPrefixUrl | string | Optional URL prefix for asset sources |
cardLoading | boolean | Optional flag to show loading state |
marketplaceType | MarketplaceType | Optional. Type of marketplace (‘market’ or ‘shop’) |
isTradable | boolean | Optional flag indicating if the item can be traded |
Shop Card Props
Additional properties for shop cards (marketplaceType="shop"
):
Parameter | Type | Description |
---|---|---|
salesContractAddress | Address | The address of the sales contract |
tokenMetadata | TokenMetadata | Metadata for the token including name, description, image |
salePrice | object | Optional. Price information including amount and currency |
saleStartsAt | string | Optional. Sale start timestamp |
saleEndsAt | string | Optional. Sale end timestamp |
quantityDecimals | number | Optional. Number of decimals for quantity |
quantityInitial | string | Optional. Initial supply amount |
quantityRemaining | string | Optional. Remaining supply amount |
unlimitedSupply | boolean | Optional. Whether the supply is unlimited |
Market Card Props
Additional properties for market cards (marketplaceType="market"
):
Parameter | Type | Description |
---|---|---|
orderbookKind | OrderbookKind | Optional. Type of orderbook |
collectible | CollectibleOrder | Optional. Collectible order information |
onCollectibleClick | function | Optional. Handler for collectible click events |
onOfferClick | function | Optional. Handler for offer click events |
balance | string | Optional. User’s balance of this collectible |
balanceIsLoading | boolean | Whether the balance is currently loading |
onCannotPerformAction | function | Optional. Handler for unauthorized actions |
prioritizeOwnerActions | boolean | Optional. Whether to prioritize owner actions in UI |
Features
Card Variants
The component supports two main variants:-
Market Card: Used for displaying collectibles in a marketplace context with:
- Current listing price
- Highest offer indicator
- Balance/ownership information
- Buy/Offer actions
-
Shop Card: Used for primary sales with:
- Sale price
- Supply information
- Sale status
- Purchase actions
Automatic Type Detection
The component automatically handles different token standards:- ERC-721 (Non-fungible tokens)
- ERC-1155 (Semi-fungible tokens)
Loading States
Built-in loading states are provided:Price Formatting
The component includes sophisticated price formatting with:- Currency symbol display
- Overflow/underflow indicators
- Support for various token decimals
- “Free” indicator for zero prices
Integration Examples
Market Content Integration
Here’s a complete example of integrating the CollectibleCard in a marketplace context:Shop Content Integration
Example of integrating the CollectibleCard in a shop context with contract type handling:Notes
TheMarketplaceCollectibleCard
component is designed to handle various marketplace scenarios with:
- Responsive layout
- Loading states
- Price formatting
- Supply tracking
- Action handling
- Owner-specific features
- Offer management
- Balance is displayed as “Owned: X” format
- Supply information is shown for shop items
- Quantity tracking is supported
Best Practices
-
Data Fetching
- Use the appropriate data hook based on your context (market/shop) and contract type (ERC721/ERC1155)
- Enable conditional fetching using the
enabled
prop when necessary - Handle loading states appropriately
-
Event Handling
- Implement click handlers for both the card and specific actions (buy, offer)
- Use the
onCannotPerformAction
callback to handle unauthorized actions
-
Display
- Wrap cards in buttons for clickable behavior
- Use appropriate className for layout and spacing
- Consider implementing infinite scroll or pagination for large collections