API
This section will walk you through the required steps to get quote and submit a swap using Mosaic Aggregator.
Last updated
This section will walk you through the required steps to get quote and submit a swap using Mosaic Aggregator.
Last updated
To retrieve the best swap rate, send the following HTTP request to get a quote:
This will return the best available quote for swapping the source asset (AptosCoin) into the destination asset (USDC) based on current market conditions.
Here is a detailed guide using Typescript:
Import the required libraries and initialize your connection to the Aptos testnet using the AptosConfig
and Aptos
objects from the @aptos-labs/ts-sdk
. This sets up your environment for making requests to the Mosaic Aggregator API and interacting with Aptos.
Here, you will create an Aptos account using the user's private key. You need to fill in your own private key when initializing the account.
Specify the assets to swap and the amount (in APTOS decimals):
Retrieve the best swap rate by making a GET request to the Mosaic API.
Once you have the quote, you use the returned data (function, type arguments, and function arguments) to build a transaction that will perform the swap.
After building the transaction, you sign it using the user's private key and submit the transaction to the Aptos blockchain. The transaction hash will be logged, which can be used to check the transaction status on the explorer.
By following this guide, you will be able to integrate the Mosaic Aggregator API for performing token swaps on the Aptos network. For further assistance or inquiries, feel free to reach out to the Mosaic support team on Discord or Telegram. \
All requests to Mosaic’s API must include an X-API-Key
header for authentication. The API key is used to track your usage and ensure secure access. To obtain an API key, please contact the Mosaic team via Discord or Telegram or
Find the best quote to swap with Mosaic Aggregator
Successfully found quote
Response code
0
Response message
"successfully"
Internal request identity for tracing/troubleshooting
"f4f7aa6b2dec13ae9fe36d7622fa83f4"