Generate an multi-chain embedded wallet from a Farcaster frame
Introduction
This guide shows you how to generate an embedded wallet in both Ethereum and Solana from a Farcaster frame based on an email address input.
We will use a frame building library in this example, specifically Frog.fm however you can use any frame builder you like.
Implementation
Step 1: Configure your Dynamic app
Step 2: Bootstrap your frame
First, you’ll need to create a new frame template Frog.fm, they provide instructions on how to do this here. Specifically, they allow you to create a new frame and deploy to vercel with a single command. See here for more info.
Step 3: Check out the Dynamic API endpoint
You’ll be utilizing our new API endpoint built especially for frames. This endpoint is called POST https://app.dynamicauth.com/api/v0/environments/{environmentId}/embeddedWallets/farcaster
and it takes in a JSON object with the following properties:
The full reference for the endpoint can be found here
The chains
property is an array of the chains you want to support with the wallet. Currently, the supported chains are EVM
and SOL
.
The email
property is the email address of the user you want to generate the wallet for, it must be a valid email.
The fid
property is the Farcaster user ID for whom you want to use to generate the wallet. You can find the FID for a user from within the Warpcast profile tab by clicking on the three dots and choosing “about”.
Step 4: Define our creation function a frame with an email input
In your frame code, you’ll need to define a function that will be called when the user submits their email address. This function will call the Dynamic API endpoint to generate the wallet and then display the wallet to the user.
Note that the key
should be a Dynamic.xyz API key. You can get one from the
following page: https://app.dynamic.xyz/dashboard/developer/api (you can find
your ENVIRONMENT_ID on the same page)
Step 5: Call the creation function when the user submits their email
For this we will need to define our frame UI and call the createEmbeddedWallet
function on submit. it will look like this:
Step 6: Test the frame
You can now test the frame by running it locally and entering an email address. You should see the wallet address displayed on the screen after you submit the email address.
Step 7: Deploy the frame
With Frog.fm you can deploy quickly using Vercel. They have a great guide for it here.
Step 8: Connect to your dApp
Now that you’ve created embedded wallets for your users, which are linked to their email and Farcaster ID so you can set up Dynamic with your dApp, and the user can log into your dApp with either their email or Farcaster account to access their embedded wallets!
Was this page helpful?