Welcome to this starter kit for building onchain applications! This project demonstrates how to build a modern web3 application using Next.js, Privy, and WAGMI. It's designed to help you understand core web3 concepts and how to implement them in a production-ready application.
Next.js is a React framework that provides:
- Server-side rendering for better performance and SEO
- File-based routing for easy navigation
- API routes for backend functionality
- Built-in TypeScript support
- Excellent developer experience
Privy is a powerful authentication and wallet management solution that offers:
- Embedded Wallets: Non-custodial wallets that users can create with just an email or social login
- Smart Wallets: Programmable wallets that can execute complex transactions
- Seamless onboarding for web3 newbies
- Secure key management
WAGMI (We're All Gonna Make It) is a React Hooks library for Ethereum that:
- Provides easy-to-use hooks for interacting with Ethereum
- Handles wallet connections and chain switching
- Manages transaction states and error handling
- Integrates seamlessly with Privy
This starter kit demonstrates:
- How to set up Privy authentication
- Creating and managing embedded wallets
- Using smart wallets for complex transactions
- Signing messages and sending USDC transactions
- Switching between different networks (Base and Base Sepolia)
- Displaying wallet balances
- Building a responsive UI with NextUI
- Clone the repository:
git clone https://github.com/builders-garden/privy-advanced-wallets
- Install dependencies:
yarn install
-
Set up your environment variables:
Create a
.env.local
file in the root directory and add your Privy App ID (learn how to get one here):
NEXT_PUBLIC_PRIVY_APP_ID=your_app_id_here
- Run the development server:
npm run dev
Open http://localhost:3000 to see your application in action.
app/
: Contains the main application pages and layoutpage.tsx
: Main application page with the dashboard layoutlayout.tsx
: Root layout with providers and global styles
The application is built using modular components that handle specific functionality:
Header.tsx
: Navigation bar with wallet connection and network switchingEmbeddedWallets.tsx
: Manages embedded wallet creation and connectionWalletInfo.tsx
: Displays information about the connected embedded walletSmartWallets.tsx
: Handles smart wallet creation and managementSmartWalletInfo.tsx
: Shows details about the connected smart wallet
USDCTransaction.tsx
: Handles USDC transfers using embedded walletsSmartUSDCTransaction.tsx
: Manages USDC transfers using smart walletsSignMessage.tsx
: Component for signing messages with embedded walletsSmartSignMessage.tsx
: Component for signing messages with smart wallets
Tabs.tsx
: Tab navigation component for switching between different featuresProviders.tsx
: Sets up all necessary providers (Privy, WAGMI, etc.)
-
lib/
: Core configuration and utility filesconstants.ts
: Network configurations and contract addresseswagmi.ts
: WAGMI client configuration and setuputils.ts
: Helper functions for common operations
-
public/
: Static assets (images, fonts, etc.)
- Users can sign in using email or social login
- Privy handles the creation of embedded wallets
- WAGMI manages the wallet connection to Base and Base Sepolia
- Session management is handled automatically
- Programmable wallets that can execute complex transactions
- Gas sponsorship capabilities
- Transaction batching
- Recovery mechanisms
- USDC transfers between wallets
- Message signing for authentication
- Chain switching between Base and Base Sepolia
- Transaction status tracking
- Next.js Documentation
- Privy Documentation
- Privy Smart Wallets Guide
- WAGMI Documentation
- NextUI Documentation
This project is optimized for deployment on Vercel. Here's how to deploy:
- Push your code to a GitHub repository
- Sign up for a Vercel account
- Create a new project and import your repository
- Add your environment variables in the Vercel dashboard
- Deploy!
For more detailed deployment instructions, check out:
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is open source and available under the MIT License.
If you're stuck or have questions:
- Check the documentation links above
- Join the Privy Discord community
- Open an issue in this repository