In this lesson, we’ll walk through how to verify a challenge when working with user-controlled wallets using Circle’s Web3 SDK. This is a crucial part of securing operations like wallet creation and token transfers.
To begin, we check the wallet balance to ensure there are sufficient funds.
npm run checkWalletBalance
In this example, the wallet contains 20 USDC. For demonstration, we’re transferring tokens to the same wallet.
To initiate the transaction:
npm run initiateTransaction
This command returns three important values:
We move to the wallet creation interface from the previous project. Although the context is different (user-controlled wallet vs transaction), the verification process remains the same.
You’ll need the following parameters:
Once these are filled, clicking "Verify Challenge" and entering your password will initiate the verification process.
After submission, you should see:
This demonstrates that the challenge flow works successfully for user operations.
All the logic for challenge handling is in createWalletForm.jsx under components. Here’s how it’s implemented:
Install the SDK:
Initialize the SDK using useEffect in React. This prepares the SDK for use.
Load Credentials: App ID, User Token, Encryption Key, and Challenge ID are pulled from local storage or passed through props.
Authentication:
Execute Challenge:
The UI includes fields to input:
There's a button to "Verify Challenge", linked to the onSubmit function which calls the SDK execution.
Here’s a high-level summary of the challenge verification workflow:
This process is straightforward and integrates well with front-end frameworks like React. You already have the code; working through it directly will help you become comfortable using it in your projects.
Swap insights and ask questions about “Learn everything about Circle and USDC”.
Ask a question or share your thoughts about this lesson.