This project is a Demo for sending SOL tokens on the Solana blockchain. It consists of:
- A Rust smart contract (Anchor) deployed to Solana devnet.
- A React frontend that allows users to send SOL using their Phantom Wallet.
The frontend connects to the smart contract and enables users to transfer SOL to any address on devnet.
- The Rust smart contract (
programs/sender) exposes asend_solinstruction. - The frontend React app (
app/) connects to the user's Phantom Wallet and calls the smart contract using Anchor's JS bindings. - Users input a recipient address and amount, and the transaction is sent via the smart contract.
- Install Solana CLI and Anchor:
curl --proto '=https' --tlsv1.2 -sSfL https://solana-install.solana.workers.dev | bash npm install -g @coral-xyz/anchor-cli
- Create and fund a wallet on devnet:
solana-keygen new solana config set --url devnet solana airdrop 2 solana balance - Sync wallet with Anchor project:
anchor keys sync
- Build and deploy the Rust program:
anchor build anchor deploy
- Copy the generated IDL to the frontend:
cp target/idl/sol_transfer.json app/src/
- Install frontend dependencies and run the app:
cd app npm install npm run dev - Connect Phantom Wallet and send SOL:
- Open the app in your browser.
- Connect your Phantom Wallet (ensure it's set to Devnet).
- Enter a recipient address and amount, then click Send.
- View the transaction on Solscan via the provided link.
- Transaction fails:
- Ensure you have enough SOL in your wallet.
- Make sure Phantom is set to Devnet.
- Check the recipient address is valid.
- Check transaction status:
- Use the Solscan link provided after sending.
- Add support for SPL tokens.
- Improve error handling and UI feedback.
- Add more comprehensive tests for the smart contract.
- Provide deployment scripts for easier setup.