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 an app for performing your first USDC transfer on Aptos.

Prerequisites

Before building the sample app for USDC transfer on Aptos, ensure you have the following:
  • Node.js and npm: Ensure 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.
  • Aptos Wallet: Install the Aptos Wallet browser extension and set up your wallet. Ensure that your wallet is funded with:

Contract Addresses

You will need the following contract addresses:

Installation

Perform the following installation and setup steps:
  1. 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. Copy the following code into 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 Circle’s faucet if needed.
  • Click on Request testnet Aptos Tokens from your Aptos 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 status.

Sample App UI

Successful Transaction

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