A modern React-based Web3 adapter for Solana blockchain integration, featuring a clean UI built with Tailwind CSS and shadcn/ui components.
- 🔐 Secure wallet integration with Solana
- 💰 Real-time balance tracking with 10 seconds auto-refresh time
- 📤 Token transfer functionality using Solana Web3.js
- ✍️ Message signing with Ed25519 verification
- 🎨 Modern UI with Tailwind CSS and shadcn/ui components
- 🌐 Devnet support with SOL airdrop functionality
graph TD
A[App.jsx] --> B[WalletProvider]
A --> C[ConnectionProvider]
B --> D[RequestAirdrop]
B --> E[Balance]
B --> F[SendTokens]
B --> G[SignMessage]
D --> H[Solana Connection]
E --> H
F --> H
G --> H
sequenceDiagram
participant User
participant Wallet
participant Components
participant Solana
User->>Wallet: Connect Wallet
Wallet->>Components: Update Connection State
Components->>Solana: Establish RPC Connection
alt Balance Check
Components->>Solana: getBalance()
Solana-->>Components: Return SOL Balance
end
alt Send Tokens
User->>Components: Input Recipient & Amount
Components->>Solana: Create Transaction
Solana-->>Wallet: Request Signature
Wallet-->>User: Confirm Transaction
User->>Wallet: Approve
Wallet->>Solana: Send Signed Transaction
end
alt Sign Message
User->>Components: Input Message
Components->>Wallet: Request Signature
Wallet-->>User: Confirm Signing
User->>Wallet: Approve
Wallet->>Components: Return Signature
Components->>Components: Verify with Ed25519
end
- Node.js 16.x or higher
- npm 7.x or higher
- A Solana wallet (Phantom, Solflare, etc.)
- Clone the repository:
git clone https://github.com/yourusername/web3-adapter.git
cd web3-adapter- Install dependencies:
npm install- Start the development server:
npm run devsrc/
├── components/ # Reusable UI components
│ ├── ui/ # shadcn/ui components
│ │ ├── button.jsx # Custom button component
│ │ └── input.jsx # Custom input component
│ └── Background.jsx # Gradient background component
├── lib/ # Utility functions
│ └── utils.js # Tailwind class merging utilities
├── App.jsx # Main application component with providers
├── Balance.jsx # SOL balance tracking (10s refresh)
├── RequestAirdrop.jsx # Devnet SOL airdrop functionality
├── SendTokens.jsx # SOL transfer with web3.js
└── SignMessage.jsx # Message signing with ed25519
<ConnectionProvider endpoint="https://api.devnet.solana.com">
<WalletProvider wallets={[]} autoConnect>
<WalletModalProvider>
// Application components
</WalletModalProvider>
</WalletProvider>
</ConnectionProvider>const { connection } = useConnection();
const wallet = useWallet();
useEffect(() => {
const intervalId = setInterval(async () => {
if (wallet.publicKey) {
const balance = await connection.getBalance(wallet.publicKey);
// Update UI with balance in SOL
}
}, 10000);
return () => clearInterval(intervalId);
}, [wallet.publicKey]);This project follows these coding best practices:
-
Component Structure
- Small, focused components
- Single responsibility principle
- Clear separation of concerns
-
Code Organization
- Modular file structure
- Consistent naming conventions
- Logical grouping of related files
-
State Management
- Efficient use of React hooks
- Proper state isolation
- Controlled component patterns
-
Performance
- Optimized re-renders
- Proper dependency management
- Efficient blockchain interactions
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by Vedant Anand
- GitHub: @VedantAnand17
- LinkedIn: Vedant Anand
- Twitter: @Vedantsx