Skip to main content
USDC provides the ability to transfer digital dollars over public blockchains using smart contracts. The USDC smart contract allows you to send, receive, and store digital dollars onchain with a wallet. This quickstart guide provides step-by-step instructions to build a React app that allows users to connect their wallet and send USDC transactions over Sonic Blaze Testnet.

Prerequisites

Before you begin, make sure you have:
  • Installed Node.js and npm. You can download and install Node.js from Nodejs.org. npm comes with Node.js.
  • Installed Metamask
  • Some Sonic testnet tokens in your wallet to cover transaction fees. You can use the Sonic Faucet.
  • Testnet USDC tokens in your wallet for the transfer. You can use the CCTP Sample App to move testnet USDC from Ethereum Sepolia to Sonic Blaze.

Contract address

You will need the following contract address for the USDC token on Sonic Blaze Testnet:

Part 1: Set up your project

Perform the following installation and setup steps:
  1. Create a new project directory and initialize it with npm:
Shell
  1. Install the required dependencies:
Shell
  1. Verify the installation by checking the package.json file. It should look like this:
JSON
If your package.json file does not contain the scripts section, copy and paste it from the above code into your file. Test that you can run the project with the command:
Shell

Part 2: Import clients and set up helpers

Perform the following steps to import code and set up helpers for the application.
  1. Create a new file src/client.ts and copy the following code into it. This code imports required libraries and sets up the network configuration.
Typescript
  1. Define the USDC testnet token contract details in a new file src/constants.ts. This file contains the contract address and Application Binary Interface (ABI) for the USDC token on Sonic Blaze.
Typescript

Part 3: Create the main application component

The following steps create the main application component and show the steps to connect a wallet and transfer USDC.
  1. Create a new file src/App.tsx and copy the following code into it. This code contains the main application component that allows users to connect their wallet and transfer USDC.
Typescript
  1. Create your application entrypoint by creating a new file src/main.tsx and copying the following code into it. This code sets up the React application and renders the USDCApp component.
Typescript
  1. Create a new file index.html in the root directory and copy the following code into it. This code sets up the HTML structure for the application.
HTML
  1. Run your application using the following command:
Shell
You can open http://localhost:5173 in your browser to view the application.

Connecting your wallet

  • In the application, click the Connect Wallet button. This will prompt you to connect your wallet using Metamask.
  • Select your Sonic wallet address from the available options.
  • Approve the connection request in Metamask.

Transferring USDC

  • In the app, enter the amount of USDC to send, and the recipient’s wallet address.
  • Click Send Tokens
  • Review the transaction details in the Metamask pop-up and approve the transaction.
  • Wait for the transaction to be confirmed. The app displays the transaction hash and status once the transfer is complete.
  • You can check the transaction status on the Sonic Explorer.