USDC quick start guide
USDC provides the ability to transfer dollars over the Arbitrum network using a smart contract. The smart contract enables users to send, receive, and store dollars on-chain with a wallet.
This guide will walk you through using the viem framework to build a simple app that enables a user to connect their wallet and interact with the blockchain by sending a USDC transaction from their address.
Prerequisites
Before you start building the sample app to perform a USDC transfer, ensure you meet the following prerequisites:
-
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.
-
MetaMask: Install the MetaMask browser extension and set up your wallet. Ensure that your wallet is funded with:
- Some native gas tokens (e.g., ETH on the Sepolia network) to cover transaction fees.
- USDC tokens for the transfer. (USDC Testnet Faucet)
-
Project Setup: Create a new project directory and initialize it with npm:
mkdir usdc-transfer-app
cd usdc-transfer-app
npm init -y
- Dependencies: Install the required dependencies using the following command:
npm install react@^18.2.0 react-dom@^18.2.0 @types/react@^18.0.27 @types/react-dom@^18.0.10 @vitejs/plugin-react@^3.1.0 typescript@^5.0.3 vite@^4.4.5
This will set up your development environment with the necessary libraries and tools for building a React application with TypeScript and Vite.
Installation
To install viem run the following command.
npm i viem
Setup public client
The public client is used to interact with your desired blockchain network.
import { http, createPublicClient } from 'viem';
import { arbitrumSepolia } from 'viem/chains';
const publicClient = createPublicClient({
chain: arbitrumSepolia,
transport: http(),
});