Show NFT Collectibles in Your Wallet
Complete your realtime crypto wallet by adding a visual display of a user’s NFT collection.
The user's full NFT collection, with artwork and details, displayed in the 'Collectibles' tab.
Your wallet now displays token balances, calculates total portfolio value, and tracks detailed account activity. To give users a holistic view of their onchain assets, the final piece is to showcase their NFT collections. In this third and final guide of our wallet series, we will focus on implementing the Collectibles tab.
View Source Code
Access the complete source code for this wallet on GitHub
Try Live Demo
Interact with the finished wallet app
This guide assumes you have completed the previous guides:
Explore the NFT Collection
See the collectibles feature in action with the live demo below. Click on the “Collectibles” tab to browse the sample wallet’s NFT collection:
Fetch NFT Collectibles
Let’s add a new asynchronous getWalletCollectibles
function to server.js
to fetch a user’s NFT collection using the Collectibles API.
The NFT data is extracted from the entries
array within this response, providing information like contract addresses, token IDs, and chain data.
The Collectibles API supports pagination using limit
and offset
query parameters.
For wallets with many NFTs, you can implement logic to fetch subsequent pages using the next_offset
value returned by the API to provide a complete view of the user’s collection.
Fetch NFT Images
Sim APIs provide comprehensive blockchain metadata for NFTs, but we images to create a rich visual experience. We’ll integrate with OpenSea’s API to enrich our NFT data with image URLs.
NFT image data and enhanced metadata might be coming soon to the Sim APIs, but for now you can use OpenSea APIs to grab image URLs and provide a visual NFT display for users.
Get an OpenSea API Key
Before we can fetch NFT images from OpenSea, you’ll need to obtain an OpenSea API key.
Once you receive your API key, add it to your .env
file:
Update getWalletCollectibles
Let’s complete the getWalletCollectibles
function by adding OpenSea API integration to fetch images:
This enhanced function combines blockchain data from Sim APIs with rich metadata from OpenSea.
For each NFT, we make an additional API call to OpenSea using the chain and contract information provided by Sim APIs.
The function enriches each collectible with image_url
, opensea_url
, description
, and collection_name
fields, then filters to only return NFTs that have available images for display.
Add Collectibles into the Server Route
Next, we update our main app.get('/')
route handler in server.js
to call this new function:
The route handler now fetches balances, activities, and the enriched NFT collectibles data concurrently for optimal performance.
The collectibles
array, now containing both blockchain data and image URLs, is passed to the wallet.ejs
template.
Display Collectibles in the Frontend
The final step is to modify views/wallet.ejs
to render the fetched collectibles within the “Collectibles” tab.
We will use a grid layout to display NFT images with their collection names and token IDs.
In views/wallet.ejs
, find the section for the “Collectibles” tab (you can search for id="collectibles"
).
It currently contains a placeholder paragraph.
Replace that entire div
with the following EJS:
The EJS template iterates through the collectibles
array and displays each NFT with its enriched metadata.
Each collectible shows the image_url
from OpenSea, the collection_name
or fallback name, and a truncated token_id
for identification.
If an opensea_url
is available, the entire NFT card becomes a clickable link that opens the NFT’s OpenSea page in a new tab.
Restart your server using node server.js
and navigate to your wallet app in the browser.
When you click on the “Collectibles” tab, and if the wallet has NFTs, you should see the NFT collection displayed with rich visual metadata.
Conclusion
That concludes this three-part series! With just three API requests - Balances, Activity, and Collectibles - enhanced with OpenSea metadata, you’ve built a fully functional, multichain wallet that displays token balances, calculates portfolio value, tracks detailed transaction activity, and showcases NFT collections with rich visual displays.
This project serves as a solid foundation for a wallet. You can now expand upon it by exploring other Sim API features. Whether you want to add more sophisticated analytics, deeper NFT insights, or advanced transaction tracking, Sim APIs provides the blockchain data you need to build the next generation of onchain apps.