Account Linking With NBA Top Shot
Account Linking is a powerful Flow feature that allows users to connect their wallets, enabling linked wallets to view and manage assets in one wallet with another. This feature helps reduce or even eliminate the challenges posed by other account abstraction solutions, which often lead to multiple isolated wallets and fragmented assets.
In this tutorial, you'll build a simple onchain app that allows users to sign into your app with their Flow wallet and view NBA Top Shot Moments that reside in their Dapper Wallet - without those users needing to sign in with Dapper.
Objectives
After completing this guide, you'll be able to:
- 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
Prerequisites
Next.js and Modern Frontend Development
This tutorial uses Next.js. You don't need to be an expert, but it's helpful to be comfortable with development using a current React framework. You'll be on your own to select and use a package manager, manage Node versions, and other frontend environment tasks. If you don't have your own preference, you can just follow along with us and use Yarn.
Flow Wallet
You'll need a Flow Wallet, but you don't need to deposit any funds.
Moments NFTs
You'll need a Dapper Wallet containing some Moments NFTs, such as NBA Top Shot Moments.
Getting Started
This tutorial will use a Next.js project as the foundation of the frontend. Create a new project with:
_10npx create-next-app@latest
We will be using TypeScript and the App Router, in this tutorial.
Open your new project in the editor of your choice, install dependencies, and run the project.
_10yarn install_10yarn run dev
If everything is working properly, you'll be able to navigate to localhost:3000
and see the default Next.js page.
Flow Cadence Setup
You'll need a few more dependencies to efficiently work with Cadence inside of your app.