Overview
This guide shows how to use Magic’s Embedded Wallet to send USDC on Solana. Users authenticate with Magic, and your app builds an SPL token transfer transaction, signs it via Magic’s Solana extension, and broadcasts it to the network.Prerequisites
Before starting, ensure you have:- A Magic Publishable API Key from your Magic Dashboard
- A Solana RPC endpoint (e.g., from Helius or QuickNode)
- USDC in the user’s Solana wallet
- SOL for transaction fees (typically ~0.000005 SOL per transaction)
How It Works
- User authenticates with Magic
- Magic SDK creates an Embedded Wallet with a Solana keypair
- Your app builds an SPL token transfer instruction with the recipient and amount
- The transaction is signed via
magic.solana.signTransaction()and broadcast to the network
On Solana, USDC is an SPL token — not a smart contract like ERC-20. Each wallet needs an Associated Token Account (ATA) to hold USDC. If the recipient doesn’t have one, your app must create it as part of the transaction.
Setting Up the Client
Initialize Magic with the Solana extension and create a connection to the Solana network.TypeScript
Token Setup
Define the USDC mint address and helper to get Associated Token Accounts.TypeScript
Sending USDC
Build the SPL token transfer instruction, creating the recipient’s token account if needed.TypeScript
Creating a recipient’s Associated Token Account costs ~0.002 SOL in rent. This is a one-time cost — subsequent transfers to the same recipient skip this step.
Checking Balance
Query the user’s USDC token account to display their balance.TypeScript
Token Addresses
Key addresses on Solana mainnet:TypeScript
Solana uses mint addresses instead of contract addresses. Each SPL token has a unique mint, and wallets hold tokens in Associated Token Accounts (ATAs) derived from the mint and owner.
Key Dependencies
| Package | Purpose |
|---|---|
magic-sdk | Magic authentication and Embedded Wallet |
@magic-ext/solana | Solana extension for Magic |
@solana/web3.js | Solana client for transactions |
@solana/spl-token | SPL token transfer instructions |
Troubleshooting
Transfer fails with insufficient funds
Transfer fails with insufficient funds
Symptoms: Transaction simulation fails before sending.Solutions:
- Check that the user has enough USDC in their token account
- Ensure the user has SOL for transaction fees (~0.000005 SOL)
- If creating a recipient ATA, the user needs ~0.002 SOL for rent
Token account not found
Token account not found
Symptoms:
getAccount throws an error for the sender’s ATA.Solutions:- The user’s wallet may not have a USDC token account yet
- Send USDC to the wallet first — this creates the ATA automatically
- You can create the ATA manually with
createAssociatedTokenAccountInstruction
Transaction confirmation timeout
Transaction confirmation timeout
Symptoms:
confirmTransaction takes too long or times out.Solutions:- Solana transactions typically confirm in 1-2 seconds
- Check the transaction on Solana Explorer using the signature
- Try using a different RPC endpoint if you’re hitting rate limits
- Increase the commitment level to
"confirmed"instead of"finalized"
Resources
Magic Solana Guide
Magic SDK setup for Solana
Solana Documentation
Official Solana developer documentation
SPL Token Program
Documentation for the SPL Token standard
USDC on Solana
Learn about Circle’s USDC stablecoin