Module 1 - PathFinder API Flow
PathFinder API Architecture
Follow this Repository to see the Code of the dApp we’re Building.
Step 1: Get the Quote
Step 2: Check and Set Allowance
Step 3: Execute the Transaction
Step1: Get the Quote
Router Nitro enables you to Interact with the Nitro Contract and initiate cross-chain Token Transfers. The First Step in this Process is to Request a Quote, which provides you with Essential Details about the Proposed Token Transfer.
To Request a Quote, follow these Steps:
-
Define the PATH_FINDER_API_URL: Set the PATH_FINDER_API_URL Variable to the URL of the Pathfinder API for the Voyager Testnet. This is where you will send your Quote Request.
-
Create the
getQuote
Function: This Function handles the Quote Request. It uses theaxios
Library to make an HTTP GET Request to the Voyager Pathfinder API. -
Call the
getQuote
Function: Use this Function to Request a Quote by passing appropriate Parameters. In this Repository, this Function is called using a button.These Parameters Define the Details of the Token Transfer you wish to Execute. Let’s Break down what each Parameter represents:
-
'fromTokenAddress'
: This should specify the address of the Token you want to Transfer from (the Source Token). -
'toTokenAddress'
: Provide the Address of the Token you want to Transfer to (the Dstination Token). -
'amount'
: Set the Amount of the Token you wish to Transfer. -
'fromTokenChainId'
: This Parameter Represents the Chain ID of the Source Blockchain. In this Case, it’s Set to “80001.” -
'toTokenChainId'
: Similarly, this Parameter Specifies the Chain ID of the Destination Blockchain, which, in this example, is “43113” (Fuji). -
'widgetId'
: This Parameter is used to identify the Widget Responsible for the Transfer. For now, Keep it as 0.
With these Parameters, you can now Call the
getQuote
Function with thisparams
Object to initiate a Quote Request for your Specific Token Transfer. -
Response
The getQuote
Function returns the Quote Data, which typically includes Details about the Token Transfer, such as Source and Destination Chains, Token Amount, Fees, and other Relevant Information. Click the Get Quote
Button and go to console to see the Quote Data printed on console.