Farcaster Miniapp
A user-friendly Farcaster miniapp for interacting with NFT liquidity pools. Built with Next.js 14, Wagmi, and the Farcaster Miniapp SDK.
NFT Liquidity Pool Miniapp
A Farcaster miniapp for interacting with NFT liquidity pools built on the LSSVM protocol.
Features
- Pool Discovery: Enter pool addresses to view pool details
- Buy NFTs: Purchase NFTs from liquidity pools using ETH or ERC20 tokens
- Sell NFTs: Sell your NFTs to liquidity pools in exchange for tokens
- Real-time Quotes: Get up-to-date pricing information before trading
- Transaction Tracking: Monitor transaction status with explorer links
Setup
- Install dependencies:
npm install
- Create a
.env.localfile with your contract addresses:
# Base Sepolia (chainId: 84532)
NEXT_PUBLIC_ROUTER_ADDRESS_84532=0x...
NEXT_PUBLIC_FACTORY_ADDRESS_84532=0x...
# Base Mainnet (chainId: 8453)
NEXT_PUBLIC_ROUTER_ADDRESS_8453=0x...
NEXT_PUBLIC_FACTORY_ADDRESS_8453=0x...
-
Update
public/.well-known/farcaster.jsonwith your domain and sign it using the Farcaster Manifest Tool -
Run the development server:
npm run dev
Project Structure
app/- Next.js app router pagespage.tsx- Home page with pool address inputpool/[address]/page.tsx- Pool detail pagebuy/[poolAddress]/page.tsx- Buy NFTs interfacesell/[poolAddress]/page.tsx- Sell NFTs interface
components/- React componentsPoolCard.tsx- Pool summary cardPoolDetails.tsx- Detailed pool information displayNFTSelector.tsx- NFT selection componentPriceQuote.tsx- Price breakdown displayTransactionStatus.tsx- Transaction status indicator
hooks/- React hooks for data fetchingusePoolData.ts- Fetch pool informationuseBuyQuote.ts- Get buy price quotesuseSellQuote.ts- Get sell price quotesuseUserNFTs.ts- Fetch user's NFTsuseTokenData.ts- Fetch token information
lib/- Utility functions and contract ABIscontracts.ts- Contract ABIs and typespool.ts- Pool data fetching utilitieswagmi.ts- Wagmi configuration
Contract Integration
The miniapp integrates with:
LSSVMRouter- Main router contract for executing swapsILSSVMPair- Pair contract interface for pool data- ERC721/ERC1155 - NFT standards
- ERC20 - Token standard
Deployment
- Build the project:
npm run build
-
Deploy to Vercel, Netlify, or your preferred hosting platform
-
Update the
farcaster.jsonmanifest with your production domain -
Sign the manifest using your Farcaster custody address
Notes
- The app currently supports manual pool address entry. For production, consider integrating with an indexer or subgraph for pool discovery.
- NFT metadata fetching (images, names) is not implemented. Consider integrating with IPFS or a metadata service.
- User NFT fetching uses
tokenOfOwnerByIndexwhich may not be supported by all ERC721 contracts. Consider using an indexer for production.
Configuration
Required Environment Variables
All environment variables must be prefixed with NEXT_PUBLIC_ to be accessible in the browser.
RPC Configuration
NEXT_PUBLIC_BASE_RPC_URL- RPC endpoint URL for Base Mainnet (required to avoid rate limits)- Example:
https://base-mainnet.g.alchemy.com/v2/YOUR_API_KEY - Defaults to public endpoint if not set (may hit rate limits)
- Example:
IPFS Configuration
NEXT_PUBLIC_IPFS_URL- IPFS gateway URL for resolving IPFS metadata and images- Example:
https://sapphire-dear-marsupial-522.mypinata.cloud(Pinata gateway) - Defaults to
https://ipfs.ioif not set - Used for fetching NFT metadata stored on IPFS
- Example:
Base Mainnet (Chain ID: 8453)
NEXT_PUBLIC_ROUTER_ADDRESS_8453- Address of the LSSVMRouter contract on Base MainnetNEXT_PUBLIC_FACTORY_ADDRESS_8453- Address of the LSSVMPairFactory contract on Base Mainnet
Example .env.local file
# RPC Configuration (required to avoid rate limits)
NEXT_PUBLIC_BASE_RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_API_KEY
# IPFS Configuration
NEXT_PUBLIC_IPFS_URL=https://sapphire-dear-marsupial-522.mypinata.cloud
# Base Mainnet (chainId: 8453)
NEXT_PUBLIC_ROUTER_ADDRESS_8453=0x0000000000000000000000000000000000000000
NEXT_PUBLIC_FACTORY_ADDRESS_8453=0x0000000000000000000000000000000000000000
Notes
- Replace the placeholder addresses (
0x0000...) with your actual deployed contract addresses - All addresses must be valid Ethereum addresses (42 characters, starting with
0x) - The router address is used for executing buy/sell transactions
- The factory address is available via
getFactoryAddress()but may not be currently used in the UI