This demo showcases how to use Flow Account Linking to view NBA Top Shot Moments from a user's Dapper Wallet using their Flow Wallet login. No asset transfers or separate Dapper login required.
✅ Built with Next.js (App Router) + Flow FCL + Cadence
🔗 Try it live: nextjs-topshot-account-linking.vercel.app
🧠 Learn to build it: Account Linking With NBA Top Shot
- Pull your users' NBA Top Shot Moments into your Flow app without needing to transfer them out of their Dapper wallet
- Retrieve and list all NFT collections in any child wallet linked to a given Flow address
- Write a Cadence script to iterate through the storage of a Flow wallet to find NFT collections
- Run Cadence Scripts from the frontend
WARNING: You're much better off completing the tutorial linked above. This is not a scaffold for a production app.
Click the Fork
button in the upper right. Clone your fork.
git clone https://github.com/<YOUR_GITHUB_HANDLE>/nextjs-topshot-account-linking.git
cd nextjs-topshot-account-linking
yarn install
Create a .env
file:
NEXT_PUBLIC_ACCESS_NODE_API=https://rest-mainnet.onflow.org
NEXT_PUBLIC_FLOW_NETWORK=mainnet
NEXT_PUBLIC_WALLETCONNECT_ID=<your_walletconnect_project_id>
🔐 You'll need a WalletConnect Project ID.
You'll need the Flow CLI to continue working with this project.
brew install flow-cli
yarn dev
- 🔐 Log in with Flow wallet
- 🔄 List NFTs from linked child accounts
- 📦 Script: Fetch NFTs with MetadataViews
- 💅 Styled with Tailwind CSS
.
├── app/
│ ├── components/ # NFT display logic
│ ├── hooks/ # Flow login state
│ ├── providers/ # AuthProvider context
│ ├── cadence/scripts/ # Cadence script to fetch NFTs
│ ├── layout.tsx # App-level FCL setup
│ └── page.tsx # Main app UI
├── flow.json # Flow config
├── .env # Access Node + WalletConnect
└── public/
Cadence script: FetchNFTsFromLinkedAccts.cdc
- Uses
HybridCustody
to iterate child wallets - Filters for NFT collections with accessible capabilities
- Reads metadata via
MetadataViews.Display
- A Flow Wallet to log in
- A Dapper Wallet with NBA Top Shot Moments
- Account linking completed between your wallets
- This project uses
"use client"
and suppresses hydration warnings for simplicity. - In production, you'll want to:
- Handle large NFT collections with pagination
- Filter for known contract types only
- Harden the Cadence script against storage structure changes
Brian Doyle – @briandoyle81
MIT