- Solana
- Base (EVM)
Prerequisites
- Node.js 18+ installed
- A Solana wallet keypair file
- Devnet SOL - at least 0.05 SOL recommended for transaction fees and rent (get from CDP Faucet)
- Devnet USDC tokens (get from CDP Faucet)
- A custom stablecoin to swap with (this guide uses CBTUSD, a test token on devnet)
- Basic familiarity with TypeScript
Don’t have a custom stablecoin yet? This quickstart uses CBTUSD, a test custom stablecoin already deployed on devnet for testing. For production with your own branded stablecoin, contact Coinbase about Custom Stablecoins issuance.
Don't have a Solana wallet?
Don't have a Solana wallet?
1. Create tsconfig.json
2. Install dependencies
3. Set environment variables
What do these environment variables mean?
What do these environment variables mean?
- ANCHOR_WALLET: Path to your Solana wallet keypair file
- ANCHOR_PROVIDER_URL: Solana RPC endpoint URL
- Devnet (testing):
https://api.devnet.solana.com - Mainnet (production):
https://api.mainnet-beta.solana.com
4. Get the IDL
The Stableswapper program is already deployed on Solana at program ID9vDwZVJXw5nxymWmUcgmNpemDH5EBcJwLNhtsznrgJDH (see Key Addresses).To call this program from your code, you can access its instructions and required parameters from the IDL (Interface Definition Language). This guide uses the Anchor framework to simplify interacting with the program.You can also download the IDL from Solana Explorer:- Visit the IDL page link above
- Click the download button or copy the JSON
- Save as
custom_stablecoins.jsonin your project directory
5. Create your swap script
Now we’ll create a script that swaps 0.1 USDC for the custom stablecoin (CBTUSD). The script will:- Connect to the Stableswapper program using the IDL
- Derive the required program addresses (pool, vaults, token accounts)
- Build a swap instruction with your parameters
- Submit the transaction to Solana devnet
swap.ts
6. Run your swap
Running into issues? See the Troubleshooting guide for common errors and solutions.