This example shows how to easily create in-app wallets using Snowball SDK.
See How it Works for a full explanation of the code.
In short, it allows you to create and manage your own in-app wallets
Make sure you have node
installed locally; we recommend using Node v18+.
npm install
cp .env.local.example .env.local
# Then fill out the values in .env.local
To obtain an API key:
- Sign up for an account at snowball.build
- Create a new project
- Open your new project and copy its API key
- The app starts off by initializing a Snowball instance.
- This is the primary handle you will use to manage in-app wallets throughout your app's auth process.
- [React-specific] A useSnowball hook is defined for React components to import.
- This is a generic snippet you can copy/paste into your own projects.
- The page component imports and calls
useSnowball()
, grabbing a reference to passkey auth.
Once you have a Snowball instance, you can start managing user accounts / wallets:
- If a user already has an account, just call login() and you're done!
- If not, accounts are created via calling sendOtp() on a user's email address, and verifyOtp() on the code they enter.
- After a user verifies their OTP, just call createPasskey() to prompt the user to create a new passkey for your app.
Creating a passkey not only secures your user's account, it also creates a new non-custodial wallet you can start using!
Specifically:
- It's easy to show different screens for different states, e.g. initializing, logged out, needs passkey, and so on.
- You can also just grab .wallet and check if it's available. If so, your wallet is ready to use!
npm run dev