Degen Wallet
Overview 🌟
This project aims to develop a frame for warpcast in farcaster instance to allow user to create a temporary degen wallet to buy the most trending meme coin
For this we wanted to use privy that provide an AA wallet easy to use but for the moment the integration between privy and framer are no suffisant for what we aim to perform so we create our own internal wallet for the purpose of this demo.
Frames
Frames are a standard for creating interactive and authenticated experiences on Farcaster. Create polls, live feeds or interactive galleries inside Warpcast or any other FC client.
They use static html head to generate an interactive app, with buttons and images embedded in metas. Buttons can send post requests to our server to ask for the next frame according to the user's activity. This allows us to interact with blockchain dapps as we have a way to id requests thanks to the fid (farcaster id).
This is the perfect opportunity to abstract the wallet generation as user’s already have identification from the Warpcast app.
Vision: Account abstraction for seamless swaps
We are envisioning to use Warpast’s Frame as a degen swap. The goal is to be able to connect to a wallet and swap while abstracting the wallet connection. Indeed we need account abstraction to make the inFrame swap experience seamless.
We explored different approaches to solve this problem. The first was to use the Privy service to generate an embedded wallet. Privy lets you use Farecast’s FID to generates wallet so it seemed fit for our problem.
The main issue with encountered with this approach with that while we were able to generate wallets, we couldn’t use them to execute transactions with the Privy API. We were only able to retrieve addresses, which are not enough to generate a signer in our backend. (We used a nextJS backend to generate the Frames and interact with the Base Chain.)
We then decided to take the approach of using the fid and address as well as a specific password to generate a privatekey. We then use EthersJs to generate a wallet from this privatekey. If implemented correctly, this will allow the user to enter a password in the frame and generate his wallet to interact with the Swap. (Users can easily rebuild this wallet from their password.).
Swap from the Frame
We tried different approaches for the swap. We first tried using the 1inch protocol, which is a DEX aggregator but we had issues with the API. We then tried using LiFi which is a crosschain aggregator which lets you make swaps across different chains.
The swap call is build from the etherJs signer we generated from the user’s password. The user has to first fund the account for the swap you work. It will then swap through Lifi with the user’s funds.
Project structure
We started by forking the privy frame demo. It let’s you retrieve or create a wallet from privy and then triggers a transfer to said wallet address. In the src folder, you’ll find the library folder. The forecaster.ts file handles the different frames. The swap.ts script handles the LiFi swap calls. The