Overview
This guide shows how to use Magic’s Express Server Wallet to send USDC on Base. The private key never leaves the TEE — your server builds the ERC-20 transfer transaction, signs it via the Express API, and broadcasts the result.Prerequisites
Before starting, ensure you have:- A Magic Secret Key — from your Magic Dashboard
- An OIDC Provider ID — configured for your auth provider (setup guide)
- A Base RPC endpoint (e.g., from Alchemy or QuickNode)
- A user JWT from your authentication provider
How It Works
- Your server authenticates the user and obtains a JWT
- JWT is sent to Magic’s TEE to get (or create) the user’s EOA
- Your server builds the ERC-20
transfertransaction - Transaction hash is signed via the TEE’s
/v1/wallet/sign/dataendpoint - Signed transaction is broadcast to Base via your RPC provider
TEE Request Helper
All TEE calls use the same authentication headers. Create a reusable helper for your server-side code.TypeScript
Get or Create a Wallet
Fetch the user’s wallet address. If one doesn’t exist, it will be created automatically.TypeScript
Sign and Broadcast Transactions
Build the transaction locally, compute its unsigned hash, sign via the TEE, and broadcast. This example uses viem but you can use any EVM library that can serialize unsigned transactions and compute their keccak256 hash.TypeScript
Sending USDC
Build the ERC-20transfer transaction with the recipient and amount, estimate gas, and send.
TypeScript
Checking Balance
Read the user’s USDC balance before or after a transfer.TypeScript
Contract Addresses
Key addresses on Base (chain ID 8453):TypeScript
Base has both native USDC (
0x8335...) and bridged USDbC (0xd9aA...). This guide uses native USDC, which is the standard token on Base.TEE Endpoints Used
| Endpoint | Purpose |
|---|---|
POST /v1/wallet | Get or create an EOA wallet |
POST /v1/wallet/sign/data | Sign a raw transaction hash |
Troubleshooting
TEE returns 401 or 403
TEE returns 401 or 403
Symptoms: Authentication errors when calling TEE endpoints.Solutions:
- Verify the JWT token is valid and not expired
- Check that
X-Magic-Secret-Keymatches your dashboard credentials - Ensure the OIDC Provider ID is correct
- Confirm your domain is allowlisted in the Magic Dashboard
Transfer reverts
Transfer reverts
Symptoms: The transfer transaction fails or reverts on-chain.Solutions:
- Check that the wallet has sufficient USDC balance on Base
- Verify the recipient address is valid (not the zero address)
- Ensure the wallet has ETH on Base for gas fees
Wrong token sent
Wrong token sent
Symptoms: Tokens were sent but don’t appear as USDC in the recipient’s wallet.Solutions:
- Confirm you’re using the native USDC address (
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913), not bridged USDbC - Check the transaction on Basescan to verify the token contract
Nonce errors
Nonce errors
Symptoms: Transaction fails with a nonce-related error.Solutions:
- Ensure no concurrent transactions are being sent for the same wallet
- If a previous transaction is pending, wait for it to confirm
- Fetch the nonce with
"pending"to account for in-flight transactions
Resources
Express API Docs
Learn about Magic’s Express Server Wallet API
EVM Data Preparation
Guide for preparing EVM transaction data for signing
Base Documentation
Official Base network documentation
USDC on Base
Learn about Circle’s USDC stablecoin