Now that you've set up your wallet and obtained some Testnet tokens, let's dive into initiating your first transaction. It's simpler than you might think, especially with our streamlined approach.
From a user experience standpoint, blockchain transactions have a unique challenge - gas fees. Gas fees are charges in blockchain networks that ensure transactions are processed efficiently and have to be paid with native assets, like Ether (ETH) on Ethereum. This requires your end-users to hold these native assets in their wallets to be able to transact. When using User-Controlled Wallets that are configured as smart contract wallets, you no longer require your end-users to hold native assets and pay gas fees, you can sponsor them, empowering you to provide your end-users with an improved transaction experience. This is made possible through the Gas Station, which acts as a middleman, allowing you to pay for your end-users gas fees.
During the testnet phase, the Gas Station is already set up to facilitate seamless testing and development. When transitioning to the Production phase through the Circle Developer console, you will gain even more control. You will be able to set spending limits and configure other aspects according to their specific needs. Learn more here.
Before we can proceed, we need to determine the tokenId. It is the unique identifier for the specific token type you're moving. You can do this by retrieving the token balances for your wallet. This step will also allow you to check if you have received your testnet tokens!
In the next step, we will initiate a testnet transaction, but keep in mind that as a developer, you cannot directly execute the transaction. Instead, we will create a transaction that can be approved by the end user by entering their PIN. This process, known as a Challenge, prompts the user to validate and authorize the transaction by entering their PIN within the mobile app.
To initiate this process, you will need to obtain a session token. Using the session token, you can then proceed to initiate a transfer and receive a ChallengeID in return. The ChallengeID allows you to prompt the user to enter their PIN within the app, confirming their approval and ensuring secure transaction execution.
Additionally, you will encounter the concept of gas fees in blockchain transactions. Gas fees represent the cost of executing transactions on the blockchain network. These fees vary based on factors such as network congestion and transaction complexity. Circle provides an endpoint where you can estimate gas fees, and it returns three fee options: low, medium, and high. This way you can balance cost and transaction speed. You can find more details in the official documentation. For this example, we will automatically set it to high.
A unique string that ensures your transaction isn 't processed more than once even if sent multiple times. A critical measure to prevent duplicates.
Specify the amount of tokens you're transferring.
The wallet address where you're sending the tokens.
A crucial security layer, this encrypted string ensures only authorized transactions go through.
This is the id we just extract from your wallet balance. It is the unique identifier for the specific token type you're moving. This id is unique.
Indicates the source of the transaction, i.e., from which wallet you're sending the tokens.
The above parameters are just the essentials for initiating a transaction. The endpoint offers a richer, more detailed configuration to cater to a variety of transaction types and needs. For a comprehensive understanding and to leverage advanced features, we recommend referring to the official documentation.
For demonstration purposes, you can send the transaction to the same wallet that is making the transaction.
It's important to note that the provided code snippet combines all these necessary steps into one, allowing you to create a session and initiate a transfer for testing purposes. Understanding these fundamental concepts, you are now ready to proceed with the implementation and testing of this process.
After we gathered all necessary parameters, we are now able to use our WebSDK to enter this information and start the set up process that the end user would go through.
🎉 Awesome, we now have successfully confirmed a transaction. Let's learn on the next page how to check if the transaction was successful!