Note: Use Testnet Scripts as Development Framework
- As with most of our quickstarts, all API calls and transactions in this guide take place within the testnet environment; no real-world funds will be transferred.
- The sample code in this tutorial can be adapted for real-world transactions and can serve as a framework for your further development.
Tip: Consider the EVM-Compatible Alternative TutorialYou can go through this process using an EVM compatible chain with the
EVM transfer quickstart.
USDC and Its Token Contract
USDC is a stablecoin backed 1:1 to the U.S dollar and operates natively on many public blockchains. Like many currencies, USDC is powered by a token contract, a programmable piece of code that manages user balances autonomously across a decentralized network. As transactions occur, the token contract automatically updates the digital ledger, ensuring real-time tracking of funds. This mechanism allows individuals and businesses to send and receive dollars seamlessly, capitalizing on the transparency, security, and efficiency of blockchain technology.Prerequisites
Before you begin this tutorial, you will need the following apps, tools, and accounts:- Circle Mint Sandbox Account: an account that provides access to testnet USDC.
-
Phantom: An app for creating wallets, which are
devices for storing USDC on chain:
- Create two wallets, one for sending and one for receiving testnet USDC transactions on the Solana Devnet network. These will serve as your origin wallet, from which one you send USDC, and the destination wallet, which receives USDC. Keep note of the addresses for both.
- Make sure you securely record the private key for the origin wallet.
-
Import the Solana Devnet
USDC token contract
into your origin wallet to enable it to read the token balance. Note the
contract address:
4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU
Note: Access to the Testnet ScriptsRefer to our testnet scripts.
- Node.js: JavaScript runtime environment to run code locally on your machine.
- Web3.js: JavaScript library containing functions to call the USDC token contract and initiate transactions.
- Code Editor: A source code editor of your choice. One example, Visual Studio, is available as a desktop application.
Tutorial
Follow the steps in this tutorial to transfer USDC on Solana:Set up a Circle Mint Sandbox Account to access the USDC testnet
- Navigate to Circle’s signup page, enter your information in the required fields, and click “Sign Up.” Completing the signup process takes you to the sandbox account Home:
-
Navigate to the APIs tab in the sidebar, and click the “CREATE A KEY”
button:
- Complete the “Key Name” field.
- Click the “CREATE KEY” button. A modal title “API Key Created” will populate upon success.
- Click “SHOW” to view the value of your new key.
- You must click the key to record a copy of its value.
Tip: Do not alter the API Key string:You must use the entire value of your key, including the first part of the
string, which is “SAND_API_KEY:”.
Gather Testnet USDC and SOL
You will need to use native gas tokens to pay the transaction (gas) fee:-
Configure the Circle sample sandbox application by adding your API key:
- Navigate to sample-sandbox.circle.com.
- Click on the settings (gear) menu in the top right-hand corner.
- Complete the field for “Your API Key” with the value from your sandbox account.
- Click on the hamburger button in the top left corner to access API methods.
-
Mint testnet USDC with a simulated bank transfer using methods in the Core
Functionality menu:
-
Click the
POST /businessAccount/banks/wiresmenu item.-
Click the
PREFILL FORMbutton and then chooseUS BANK ACCOUNTto add a simulated bank account for testing. -
Click the
MAKE API CALLbutton. -
Copy the value for the
idkey.
-
Click the
-
Click the
GET /businessAccount/banks/wires/{id}/instructionsmenu item.-
Complete the
Account Idfield using the value of theidkey returned from the previous step. -
Click the
MAKE API CALLbutton. -
From the successful response, record the value of the
trackingRefandaccountNumberfields.
-
Complete the
-
Click the
POST /mocks/payments/wiremenu item.-
Complete the
Tracking RefandAccount Numberfields with the values you recorded from the previous step. -
Complete the
Amountfield with a dollar amount you choose for your mock payment. -
Click the
MAKE API CALLbutton.
-
Complete the
-
Click the
-
Add the SOL wallet address to your address book:
-
You can use a REST client to make a POST request to the address recipients
endpoint. The sandbox app does not support
SOLblockchain:Shell -
Record the value of the
idfrom the successful response.
-
You can use a REST client to make a POST request to the address recipients
endpoint. The sandbox app does not support
-
Click the
POST /payoutsmenu item.-
Complete the
Amountfield with a dollar amount you choose for your mock payment. -
Complete the
idfield with the values you recorded from the previous step. -
Click the
MAKE API CALLbutton.
-
Complete the
-
Request testnet SOL:
- In a new browser tab or window, navigate to the Solana Faucet.
-
Complete the
Enter Solana account addressfield with your Fantom deposit address from step 2. - Below the wallet address input field, select the amount of SOL tokens you want.
- Select the Devnet environment. Your SOL should automatically be air dropped into your wallet upon success.
-
Make payouts in USDC from the Payouts API menu:
- From sample-sandbox.circle.com, click the Payounts APIs menu item.
-
Click the
POST /payoutsmenu item. -
Complete the
Amountfield. -
Set the
CurrencytoUSD. -
Complete the
Destinationfield with the recipient ID that corresponds to your destination wallet address. -
Select
address_bookfrom theDestination Typedrop-down. -
Complete the
Beneficiary Emailwith your recipient email address. -
Click the
MAKE API CALLbutton. -
Record the value of the
idfor your payout.
-
Monitor your payouts from the Payouts API menu:
- From sample-sandbox.circle.com, click the Payounts APIs menu item.
-
Click the
GET /payouts/{id}menu item. -
Complete the
Payout Idfield with the value of your payout ID from the previous step. -
Click the
MAKE API CALLbutton to check the status of your payout.
Install Web3.js library to enable API calls
Install Web3.js by running the command below at the command line.javasc
Customize sample JavaScript code by inputting variables
In your text editor, create a new JavaScript file calledsend10.js. Review the
commented code below to understand its structure. Copy and paste it into your
new file:
Javascript
Modify the Code
Replace the value of thePRIVATE_KEY variable with your secure private key,
which must be in Base58 format. Replace the value of the RECEIVER_PUBLIC_KEY
variable with the receiver’s public key.
Note: Transfer amount formatThe set transfer amount value of
10000000 is equal to 10 USDC. This setting is
because ISDC uses a 6 decimal place format, and the amount value should be in
the smallest unit.Execute JavaScript code to initiate USDC transfer
From the terminal command line, enter the following command to execute the code and transfer USDC:Shell