SDK
All any-to-any protocols in one SDK
Last updated
All any-to-any protocols in one SDK
Last updated
A small blazing fast wrapper over the Via Router API for on-chain and cross-chain swaps. Our API allows you to find the best route for moving funds between chains!
First you need to initialize a VIA Client instance:
Get the best routes.
Request parameters description
Pagination is needed because the request time for a specific page is faster than for all pages at once
Get allowance status
You must approve the contract to spend your token. You can get route_id from the route you like received above in the code snippet.
Build approval transaction. Returns the transaction that approves the Via API to spend your token.
Now you can build the transaction that will perform a crosschain swap according to the route.
If you want to know the status of the transaction, then you need to tell us that you started it
And start action (you can start from the second action because startRoute also handles first action)
You can see the status of the transaction.
You can use websocket
Response parameters description
With via.exchange it is possible to execute routes in several steps. This will help expand the number of available routes and, as a result, help you find the most profitable routes!
Now all you need is to sequentially execute transactions for different numAction
Multichain and Hyphen bridges don't support transfers from non-whitelist accounts. Therefore, it is necessary to filter routes with these bridges for users with multi0signature wallets.
feature | remark | method |
---|---|---|
Parameter | Description |
---|---|
Parameter | Description |
---|---|
get routes
Swaps/bridges cheapest routes
getRoutes
check allowance
Allowance to check whether it's needed or not to approve
getAllowanceStatus
build approval transaction
The transaction that approves the VIA contract to spend your token
buildApprovalTx
build transaction
The transaction that will perform a swap/bridge according to the route
buildTx
check transaction
Check the status of the transaction
checkTx
fromChainId
Source chain id
fromTokenAddress
Source token address
fromAmount
Amount
toChainId
Target chain id
toTokenAddress
Target token address
fromAddress
Sender address
multiTx
whether to return routes with multiple user transactions
offset
Pagination offset
limit
Pagination limit
retry
Time to retry in ms
event
Status of the transaction
data.started
Started time of the transaction on source chain
data.finished
Finished time of the transaction on source chain
data.txHash
Hash of the destination transaction
data.actualAmount
Received amount