Welcome. In this video, we will review what you've learned in the last section of the course, focusing on user-controlled wallets.
The project used in this section is where the provided code originates. We begin by examining the package.json file, which includes commands like:
Before running these, ensure you execute npm install to install all necessary dependencies.
Next, we look at the .env file, where we store credentials like the API key, App ID, and User ID. These were created in the previous section where we built user-controlled wallets. The goal now is to acquire a new session token, encryption key, and challenge ID, which are needed to initiate new challenges, similar to earlier steps.
We use an API call to check the wallet status by fetching variables from the .env file (User ID and API key). This is a GET method request. The response is stringified to JSON so we can visualize the output, which includes:
This data will be used in subsequent actions.
We then retrieve the wallet balance using another API call, this time requiring the Wallet ID obtained earlier. Run npm run checkWalletStatus to get the necessary details and add them to your .env file:
Once set, you can execute npm run checkWalletBalance to see the current balance. The response typically includes:
Each token includes:
Add the USDC Token ID to your .env file for later use.
Native tokens are essential for paying gas fees. USDC, although not native, is also stored and transferred using the same wallet. Each token adheres to the ERC-20 standard as Mumbai is an Ethereum Layer-2 chain. This means all smart contracts and transactions are compatible with EVM.
Before initiating a transaction, you need test tokens from:
Assuming you have these, you can proceed to initiate a transaction using the same approach as before—first by acquiring a session token and encryption key using a helper function.
These values are not stored in .env because they are temporary. You’ll also need to generate a challenge ID, which is used to present the transaction to the user through Circle’s Web SDK.
The transaction logic resides in index.js. We:
The request body includes:
We log this data to verify that the transaction has all necessary components.
Running npm run initiateTransaction will generate:
To complete the transaction, the Web SDK needs:
Once these are submitted, the user completes a simple challenge (e.g., entering a PIN). This finalizes the transaction, as the user controls the wallet.
You’ve accomplished a lot:
This replicates many functions of modern financial applications. In the next section, we’ll explore gas stations—a novel solution to manage gas fees.
Swap insights and ask questions about “Learn everything about Circle and USDC”.
Ask a question or share your thoughts about this lesson.