Skip to main content
USDC provides the ability to transfer US dollars over public blockchains using smart contracts. The smart contract allows users to send, receive, and store dollars onchain with a wallet. Here’s a quickstart guide for developers to build a web app to perform their first USDC transfer on Sui.

Prerequisites

Before you start building the sample app to perform a USDC transfer, make sure you meet the following prerequisites:
  • Node.js and npm: Make sure that you have Node.js and npm installed on your machine. You can download and install Node.js from nodejs.org. npm comes with Node.js.
  • Sui Wallet: Install the Sui Wallet browser extension and set up your wallet. Make sure that your wallet is funded with:
    • Some SUI testnet tokens to cover transaction fees.
    • USDC tokens for the transfer. (USDC Testnet Faucet)

Contract Addresses

You will need the following contract addresses:

Installation

Perform the following installation and setup steps:
  1. Project Setup: Create a new project directory and initialize it with npm:
Shell
  1. When prompted, choose the following options:
    • Use TypeScript: Yes
    • Use ESLint: Yes
    • Use Tailwind CSS: Yes
    • Use src/ directory: Yes
    • Use App Router: Yes
    • Customize the default import alias: No
  2. Navigate to the project directory:
Shell
  1. Install additional dependencies:
Shell

Import Code and Setup

  1. The code provided will be updated in the src/app/page.tsx file. This section imports necessary libraries and sets up the network configuration.
Javascript
This component handles the main functionality of the application, including wallet connection token definition, and token transfer. a. Define USDC testnet token contract
Javascript
b. State Management Define state variables to manage the connection status, amount, recipient address, and transaction status.
Javascript
c. Effect Hook for Connection Status Use useEffect() to update the connection status whenever the currentAccount changes.
Javascript
d. Token Sending Logic Define the function to handle sending tokens, including validation and transaction execution.
Javascript
e. Rendering the UI Render the main UI components, including input fields for amount and recipient address, and a button to send tokens.
Javascript

Main Application Component

This component wraps the HomeContent() function with the necessary providers for state management and wallet connection.
Javascript
  1. Start the development server:
Shell
  1. Open http://localhost:3000 in your browser.

Connecting Your Wallet

  • On the USDC Token Sender app, click the “Connect Wallet” button.
  • Select your wallet from the list of available options.
  • Approve the connection in your wallet extension.

Performing a USDC Transfer

  • Ensure you have USDC tokens in your wallet. You can get testnet tokens from our faucet if needed.
  • Click the Request testnet SUI Tokens from your Sui Wallet to source gas tokens.
  • In the app, enter the amount of USDC you want to send and the recipient’s address.
  • Click the Send Tokens button.
  • Your wallet will prompt you to approve the transaction. Review the details and confirm.
  • Wait for the transaction to be processed. The app will display the transaction to status.

Sample App UI

Successful Transaction

You can use the Sui Explorer to check the status of the transaction.