# Authentication
Source: https://docs.suave.money/checkout.suave.money/api/authentication
Authenticate with the Suave Checkout API
To request access to our API, [click here](https://suave.money).
Our API endpoints are authenticated and require the `X-Api-Key` header. This key is specific to your organization.
```json theme={null}
X-Api-Key: API_KEY
```
# Data types
Source: https://docs.suave.money/checkout.suave.money/api/data-types
Common data types used in the Suave API endpoints.
### Line Item
Line items are used to represent items to the user when they are making a payment.
```json theme={null}
{
"title": "Bored Ape NFT #1234",
"description": "A super rare NFT",
"image_url": "https://example.com/ape.jpg",
"quantity": 1
}
```
### Order Price
Order prices are used to represent the total price of an order denominated in a specific currency.
The following example represents an order price of 1 USDC.
```json theme={null}
{
"currency": "USDC",
"amount": 1000000000000000000,
"decimals": 18
}
```
# Create Payment Link
Source: https://docs.suave.money/checkout.suave.money/api/endpoint/create
POST /api/v1/payment_link
# Get Payment Order
Source: https://docs.suave.money/checkout.suave.money/api/endpoint/get
GET /api/v1/payment/{id}
# Get Routing
Source: https://docs.suave.money/checkout.suave.money/api/quote/get
GET /api/v1/quote
# null
Source: https://docs.suave.money/checkout.suave.money/api/quote/overview
## Quote API
Suave provides quotes for cross-chain token swaps. Quotes are valid for a limited time and are based on the current market rate.
### Supported Chains
Suave supports the following chains for token swap quotes (with more coming soon):
| Chain Name | Chain ID |
| ---------- | -------- |
| Ethereum | 1 |
| Arbitrum | 42161 |
| Optimism | 10 |
| Polygon | 137 |
| Base | 8453 |
# Create Webhook
Source: https://docs.suave.money/checkout.suave.money/api/webhook/create
POST /api/v1/webhook_subscription
Create a new webhook subscription for the current vendor.
# Delete Webhook
Source: https://docs.suave.money/checkout.suave.money/api/webhook/delete
DELETE /api/v1/webhook_subscription/{id}
Delete a webhook subscription with the given ID.
# Get Webhooks
Source: https://docs.suave.money/checkout.suave.money/api/webhook/get
GET /api/v1/webhook_subscription
Retrieve a list of all webhook subscriptions configured for your vendor.
Use the `env_mode` query parameter to specify the environment.
# null
Source: https://docs.suave.money/checkout.suave.money/api/webhook/overview
## Payment Webhooks
Suave provides webhooks to send updates whenever the status of a payment order changes.
This includes when a payment order is created, succeeds, or fails.
Our webhooks return metadata associated with the payment, as well as any transaction details, such as hashes and timestamps.
Events are triggered with 3 types: `payment_processing`, `payment_success`, and `payment_failed`.
### Example Payload
```json theme={null}
{
"event": {
"resource": "event",
"type": "payment_success",
"created_at": "2021-01-01T00:00:00Z",
"env_mode": "live",
"data": {
"payment_order_id": "order-id",
"metadata": { "nft-purchased": "Bored Ape NFT #1234" },
"transaction_hash": "0x1234567890"
}
}
}
```
# Introduction
Source: https://docs.suave.money/checkout.suave.money/introduction
Instantly support cross-chain transfers and token swaps with Suave
## What Is Suave Checkout?
Suave Checkout lets DApps accept any cryptocurrency of their choice across multiple blockchains.
We handle all of the necessary conversions and cross-chain asset transfers allowing for a seamless and secure transaction.
Broad cryptocurrency support with ***over 1000+ tokens*** supported across ***12+ chains***
and counting.
Simple and intuitive API for DApps to add into their platform, requiring only
a single API request and webhook response. Out-of-the-box UI components for
a seamless user experience.
Best-in-class rates for token swaps, ensuring DApps take home as much value as
possible with liquidity aggregated across multiple venues, including DEXs and
CEXs.
# null
Source: https://docs.suave.money/checkout.suave.money/sdk/components
Suave SDK provides drop-in ready components for React projects.
This includes a widget for executing swaps directly. This is the easiest way to give your users a seamless experience for swapping tokens.
This component handles all the logic to connect a wallet to our SDK and execute a swap.
Wagmi is used under the hood to connect and does require a `WalletConnectId` to be provided.
You can also override the default provider by using the `wagmiConfigOverride` prop.
### React Hooks
```javascript theme={null}
import { SuaveSDK } from 'suave-sdk';
import { useRouteEvents } from 'suave-sdk/react/routes'; //ROUTING HOOKS
import { usePaymentEvents } from 'suave-sdk/react/routes'; //Payments HOOKS
import { useEffect, useState } from 'react';
import { SuaveSDKProvider, Widget } from 'suave-sdk/react'; // Importing the necessary components
const sdk = new SuaveSDK({
apiKey: 'your-api-key'
});
// Custom hook for managing route events
// Using the custom hooks
const currentRoute = useCurrentRoute();
const routeState = useRouteState(sdk);
console.log('Current Route:', currentRoute);
console.log('Route State:', routeState);
// Main component to provide SDK context
function SDKContextProvider({ children }) {
const sdk = new SuaveSDK({
apiKey: 'your-api-key'
});
return (
{children}
);
}
// Using the SDKContextProvider and Widget
function App() {
return (
console.log('Submitted')}
onFailure={() => console.log('Failed')}
onQuote={() => console.log('Quoted')}
onRoute={() => console.log('Route')}
onLoaded={() => console.log('Loaded')}
/>
);
}
```
# null
Source: https://docs.suave.money/checkout.suave.money/sdk/execute-route
Suave SDK makes it easy to get and execute cross-chain swap routes.
This includes examples of execution and what do to in case of failure.
All execution will happen on the client side via whatever wallet provider is currently connected.
### Usage Example
```javascript theme={null}
import { SuaveSDK } from 'suave-sdk';
const sdk = new SuaveSDK({
apiKey: 'your-api-key'
});
// Get the best routes to execute a swap
await sdk.getRoutes('tokenA','chainA',amount, 'tokenB','chainB').then(routes => {
console.log('Best Routes:', routes);
return routes[0]; //the first route is the best route
});
// Execute the route
await sdk.executeRoute(route).then((txs)=>{
console.log('Txs:', txs);//List of tx receipts for the executed route.
})
.catch((error)=>{
console.error('Error:', error);
});
.on('step-update',(step)=>{ //OPTIONAL
console.log('step-update:', step); //A change of state for the steps
});
.on('step-failed',(unexecutedSteps)=>{
console.log('step-failed:', unexecutedSteps); //A step failed
//You can restart the execution in case of failure
}//OPTIONAL
)
//Restart the execution from the failed step
await sdk.executeRoute(unexecutedSteps,{
retry:2, //Retry the execution 2 more times
onRetry:(retry)=>{
console.log('retry:', retry); //A retry is about to happen
}
});
```
# null
Source: https://docs.suave.money/checkout.suave.money/sdk/get-routes
Suave SDK makes it easy to get and execute cross-chain swap routes.
### Features
* **Cross-Chain Swaps**: Execute swaps across different blockchain networks.
* **Quotes**: Routes includes quotes for each step of the route.
* **Customizable**: Adjust for different preferences, speed, price, etc.
### Usage Example
```javascript theme={null}
import { SuaveSDK } from 'suave-sdk';
const sdk = new SuaveSDK({
apiKey: 'your-api-key'
});
//Custom options for the route
const options = {
preference:'price',
feePercent: 0.01,
feeChainId:1,
feeTokenAddress:'0xa23202318e7eAf7179A845068aC64CE332Ea66B'
}
const slippagePercent = 0.5;
// Get the best routes to execute a swap
const routes = sdk.getRoutes(tokenA,chainA,amount, tokenB,chainB,slippagePercent,options).then(routes => {
console.log('Best Routes:', routes);
});
// Get the cheapest route to execute a swap
const route = sdk.getCheapestRoute(tokenA,chainA,amount, tokenB,chainB,slippagePercent,options).then(route => {
console.log('Cheapest route:', route);
});
// Get the fastest route to execute a swap
const route = sdk.getFastestRoute(tokenA,chainA,amount,tokenB,chainB,slippagePercent,options).then(route => {
console.log('Fastest route:', route);
});
//The route object is complex but does not need to used directly, instead it should be sent to the execution method.
```
## Example Route object
The route return object is a complex structure that contains the route details, quotes for each step, and the transactions required to execute the route.
```javascript theme={null}
{
id: 'eae098cd-63e4-4879-a673-ac80d53f41ec',
fromChainId: 42161,
fromAmountUSD: '10.0030',
fromAmount: '10000000',
fromToken: {
address: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
chainId: 42161,
symbol: 'USDC',
decimals: 6,
name: 'USD Coin',
priceUSD: '1.000300090027008'
},
toChainId: 10,
toAmountUSD: '9.4292',
toAmount: '9429234882404367417',
toAmountMin: '9382088707992345580',
toToken: {
address: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
chainId: 10,
symbol: 'DAI',
decimals: 18,
name: 'DAI Stablecoin',
coinKey: 'DAI',
logoURI: 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6B175474E89094C44Da98b954EedeAC495271d0F/logo.png',
priceUSD: '1'
},
gasCostUSD: '0.0087',
containsSwitchChain: true,
steps: [ {
"protocol": "Matcha",
"fromToken": "0x514910771AF9Ca656af840dff83E8264EcF986CA",
"symbol": "LINK",
"decimals": 18,
"name": "Chainlink",
"toToken": {
"chain_to_address": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"symbol": "DAI",
"decimals": 18,
"name": "Dai",
"logoURI": "https://tokens.1inch.io/0x6b175474e89094c44da98b954eedeac495271d0f.png"
},
"fromChainId": 1,
"toChainId": 1,
"inputAmount": "1000000000000000000",
"outputAmount": "25153126674823844322",
"estimatedTime": "3",
"fees": [
{
"amount": "37786364787463238",
"currency": {
"chain_to_address": {
"1": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"10": "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
"137": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
"42161": "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"
},
"symbol": "DAI",
"decimals": 18,
"chains": [
{
"id": 1,
"name": "Ethereum",
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"rpcUrls": {
"default": {
"http": [
"https://eth.merkle.io"
]
}
},
"blockExplorers": {
"default": {
"name": "Etherscan",
"url": "https://etherscan.io",
"apiUrl": "https://api.etherscan.io/api"
}
},
"contracts": {
"ensRegistry": {
"address": "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
},
"ensUniversalResolver": {
"address": "0xce01f8eee7E479C928F8919abD53E553a36CeF67",
"blockCreated": 19258213
},
"multicall3": {
"address": "0xca11bde05977b3631167028862be2a173976ca11",
"blockCreated": 14353601
}
}
},
{
"id": 137,
"name": "Polygon",
"nativeCurrency": {
"name": "POL",
"symbol": "POL",
"decimals": 18
},
"rpcUrls": {
"default": {
"http": [
"https://polygon-rpc.com"
]
}
},
"blockExplorers": {
"default": {
"name": "PolygonScan",
"url": "https://polygonscan.com",
"apiUrl": "https://api.polygonscan.com/api"
}
},
"contracts": {
"multicall3": {
"address": "0xca11bde05977b3631167028862be2a173976ca11",
"blockCreated": 25770160
}
}
},
{
"formatters": {
"block": {
"type": "block"
},
"transaction": {
"type": "transaction"
},
"transactionReceipt": {
"type": "transactionReceipt"
}
},
"serializers": {},
"contracts": {
"gasPriceOracle": {
"address": "0x420000000000000000000000000000000000000F"
},
"l1Block": {
"address": "0x4200000000000000000000000000000000000015"
},
"l2CrossDomainMessenger": {
"address": "0x4200000000000000000000000000000000000007"
},
"l2Erc721Bridge": {
"address": "0x4200000000000000000000000000000000000014"
},
"l2StandardBridge": {
"address": "0x4200000000000000000000000000000000000010"
},
"l2ToL1MessagePasser": {
"address": "0x4200000000000000000000000000000000000016"
},
"disputeGameFactory": {
"1": {
"address": "0xe5965Ab5962eDc7477C8520243A95517CD252fA9"
}
},
"l2OutputOracle": {
"1": {
"address": "0xdfe97868233d1aa22e815a266982f2cf17685a27"
}
},
"multicall3": {
"address": "0xca11bde05977b3631167028862be2a173976ca11",
"blockCreated": 4286263
},
"portal": {
"1": {
"address": "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
}
},
"l1StandardBridge": {
"1": {
"address": "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"
}
}
},
"id": 10,
"name": "OP Mainnet",
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"rpcUrls": {
"default": {
"http": [
"https://mainnet.optimism.io"
]
}
},
"blockExplorers": {
"default": {
"name": "Optimism Explorer",
"url": "https://optimistic.etherscan.io",
"apiUrl": "https://api-optimistic.etherscan.io/api"
}
},
"sourceId": 1
},
{
"id": 42161,
"name": "Arbitrum One",
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"rpcUrls": {
"default": {
"http": [
"https://arb1.arbitrum.io/rpc"
]
}
},
"blockExplorers": {
"default": {
"name": "Arbiscan",
"url": "https://arbiscan.io",
"apiUrl": "https://api.arbiscan.io/api"
}
},
"contracts": {
"multicall3": {
"address": "0xca11bde05977b3631167028862be2a173976ca11",
"blockCreated": 7654707
}
}
}
],
"name": "Dai",
"logoURI": "https://tokens.1inch.io/0x6b175474e89094c44da98b954eedeac495271d0f.png"
}
}
]
} ],
tags: []
}
```
# null
Source: https://docs.suave.money/checkout.suave.money/sdk/get-routes-streaming
While it's possible to use the `getRoutes` family of methods to retrieve routes, it's a better user experience to stream that data back to the user so that are not waiting for a batch of routes.
Our websocket connection will send over routes as they become calculated and available.
### Features
* **Cross-Chain Swaps**: Execute swaps across different blockchain networks.
* **Quotes**: Get quotes for cross-chain swaps.
* **Easy to Use**: Simplified methods for fetching and executing swaps.
### Usage Example
```javascript theme={null}
import { SuaveSDK } from 'suave-sdk';
const sdk = new SuaveSDK({
apiKey: 'your-api-key'
});
/**
* Options for the route
*/
const options = {
preference:'price',//"speed"
feePercent: 0.04,
feeChainId:137,
feeTokenAddress:'0xa23202318e7eAf7179A845068aC64CE332Ea66B'
}
const slippagePercent = 0.5;
//the .getStreamingRoutes method returns a wss url, and can be used with any websocket library
const socket = new WebSocket(sdk.getStreamingRoutes({
tokenA,chainA,amount,tokenB,chainB,slippagePercent,options
}));
socket.onopen = () => {
console.log('WebSocket connection established');
// Send a message to request routes
socket.send(JSON.stringify({
action: 'getRoutes',
tokenA,
chainA,
amount,
tokenB,
chainB
}));
};
socket.onmessage = (event) => {
const routes = JSON.parse(event.data);
console.log('Received routes:', routes);
};
socket.onerror = (error) => {
console.error('WebSocket error:', error);
};
socket.onclose = () => {
console.log('WebSocket connection closed');
};
```
# null
Source: https://docs.suave.money/checkout.suave.money/sdk/getting-started
The Suave JS SDK is simple to install and use.
### Features
* **Lightweight**: Minimal footprint for easy integration.
* **Cross-Chain Swaps**: Execute swaps across different blockchain networks.
* **Quotes**: Get quotes for cross-chain swaps.
* **Payments API**: Easily create and manage payments.
* **Easy to Use**: Simplified methods for fetching and executing swaps.
### Installation
To install the SDK:
```bash theme={null}
npm install suave-sdk
or
yarn add suave-sdk
```
### Creating your SDK instance
```javascript theme={null}
import { SuaveSDK } from 'suave-sdk';
const sdk = new SuaveSDK({
apiKey: 'your-api-key'
});
```
### Verify your current capabilities
```javascript theme={null}
import { SuaveSDK } from 'suave-sdk';
const sdk = new SuaveSDK({
apiKey: 'your-api-key'
});
sdk.getCapabilities().then(capabilities => {
console.log('Capabilities:', capabilities);
});
```
# null
Source: https://docs.suave.money/checkout.suave.money/sdk/hooks
All of our main APIs have corresponding methods in our SDK as well as React hooks for common use cases.
This includes hooks for monitoring route events, payment events, and transaction specific events that can be used to show status of on-chain transactions.
### React Hooks
```javascript theme={null}
import { SuaveSDK } from 'suave-sdk';
import { useRouteEvents } from 'suave-sdk/react/routes'; //ROUTING HOOKS
import { usePaymentEvents } from 'suave-sdk/react/routes'; //Payments HOOKS
import { useEffect, useState } from 'react';
const sdk = new SuaveSDK({
apiKey: 'your-api-key'
});
// Custom hook for managing route events
function useCurrentRoute() {
const [currentRoute, setCurrentRoute] = useState(null);
const routeEvents = useRouteEvents();
useEffect(() => {
setCurrentRoute(routeEvents);
}, [routeEvents]);
return currentRoute;
}
useEffect(() => {
if(paymentEvents.length > 0){
console.log('Payment Events:', paymentEvents);
setCurrentPayment(paymentEvents[0]);
}
}, [sdk, paymentEvents]);
// Custom hook for managing route state
function useRouteState(sdk) {
const [routeState, setRouteState] = useState(null);
useEffect(() => {
const fetchRouteState = async () => {
// Assuming there's a method in SDK to get route state
const state = await sdk.getRouteState();
setRouteState(state);
};
fetchRouteState();
}, [sdk]);
return routeState;
}
const sdk = new SuaveSDK({
apiKey: 'your-api-key'
});
// Using the custom hooks
const currentRoute = useCurrentRoute();
const routeState = useRouteState(sdk);
console.log('Current Route:', currentRoute);
console.log('Route State:', routeState);
```
# null
Source: https://docs.suave.money/checkout.suave.money/sdk/overview
## Suave SDK
The Suave JS SDK is a lightweight library that allows you to integrate Suave's cross-chain swap functionality directly into your application.
The SDK encapsulates the logic for fetching the cheapest cross-chain swap routes and executing these swaps. While the **Routing API** can retreive these routes, the SDK is the best method for executing on those routes.
The Suave SDK includes UI components, React hooks, pure JS helper functions and everything you need to make communication with our APIs a breeze.
# null
Source: https://docs.suave.money/checkout.suave.money/sdk/quotes
Get quotes from a simple sdk call.
The `getQuotes` method will return a list of quotes based on our routing engine, these quotes will be based on the user's preference for speed vs price.
If `getQuote` this method will return a single quote based on the default preference of "price".
Quotes are only valid for a short period of time, and will expire.
### Get Quotes
```javascript theme={null}
import { SuaveSDK } from 'suave-sdk';
const sdk = new SuaveSDK({
apiKey: 'your-api-key'
});
let quote = await sdk.getQuotes({
tokenA: string;
tokenB: string;
tokenAAmount: number;
chainA: string;
chainB: string;
},'speed').then(quotes => {
console.log('Quotes:', quotes);
return quotes[0];
});
// Returns back a quote object
interface Quote {
tokenA: string;
tokenB: string;
chainA: string;
chainB: string;
totalFees: [{
token:,
amount:
}
]
expirationTime: Date;
}
```
# Use Cases
Source: https://docs.suave.money/checkout.suave.money/use-cases
## Customer UX
Suave Checkout provides a seamless experience for customers to transact with DApps.
Suave Checkout allows customers to use funds from ***any*** wallet, on
***any*** chain, with ***any*** token to transact with you. Customers can
connect a self-custodial or custodial wallet and receive quotes for their
holdings.
The assets provided by the customer are converted into the cryptocurrency
of the DApp’s choosing via market makers and Decentralized Exchanges (for
low liquidity trades).
NFTs, staked tokens, points, etc. purchased by the user are provisioned
into a self-custody wallet or are bridged back to the sender’s original
wallet and chain.
## Example: Real World Assets
A fractional real estate purchasing platform built on the Algorand blockchain
would like to receive `$ALGO` tokens, in exchange for a fraction of real estate
denoted by an NFT. Suave Checkout enables customers to purchase this real
estate NFT with DAI on the Polygon blockchain. Suave Checkout provides the
quote for the amount of DAI the customer needs to pay in order to complete the
transaction. Upon payment, the NFT is bridged from Algorand to the customer’s
wallet on the Polygon blockchain.
# Get supported tokens
Source: https://docs.suave.money/suave.ag/api/get-tokens
GET /v1/tokens
We continuously expand our API with new tokens and chains, so make sure to check this endpoint regularly for the latest updates.
# Cross-chain swap routes
Source: https://docs.suave.money/suave.ag/api/routes
POST /v1/routes
Get cross-chain routes between tokens
# Overview
Source: https://docs.suave.money/suave.ag/overview
The Suave Aggregator SDK will only function properly in a browser-like environment. You can use a library like [web3-mock](https://github.com/DePayFi/web3-mock) to simulate this in Node.js.
Suave Aggregator is a multi-chain liquidity aggregation protocol that supports any-to-any swaps by aggregating bridges and exchanges.
If you prefer Swagger docs please find them [here](https://api.suave.ag/docs/).
### Supported Chains
Suave Aggregator supports the following chains for token swapping and bridging (with more coming soon):
| Chain Name | Chain ID |
| ---------- | -------- |
| Ethereum | 1 |
| Optimism | 10 |
| Polygon | 137 |
| Arbitrum | 42161 |
# Execute Routes & Quotes
Source: https://docs.suave.money/suave.ag/sdk/execute
After obtaining a route, you can delegate to the SDK to execute it.
The Suave Aggregator SDK will only function properly in a browser-like environment. You can use a library like [web3-mock](https://github.com/DePayFi/web3-mock) to simulate this in Node.js.
Use the `executeRoute` function to begin executing a route.
Here is a simple example of executing a route for bridging [10 USDC](https://arbiscan.io/token/0xaf88d065e77c8cC2239327C5EDb3A432268e5831) on Arbitrum to the maximum amount of [DAI](https://polygonscan.com/token/0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063) on Polygon. Note that you will need to configure a [Viem](https://viem.sh/) wallet client to your preferences in order to begin executing.
```ts theme={null}
import { getRoutes, RouteResponse, executeRoute } from '@suave-money/sdk'
import { createWalletClient, http } from 'viem'
import { mainnet } from 'viem/chains'
const client = createWalletClient({
chain: mainnet,
transport: http()
})
const routes: RouteResponse[] = await getRoutes({
inputAmount: '10000000', // 10 USDC
fromChainId: 42161, // Arbitrum
fromToken: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', // USDC on Arbitrum
toChainId: 137, // Polygon
toToken: '0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063' // DAI on Polygon
})
const chosenRoute = routes[0]
await executeRoute(chosenRoute, {
walletClient: client
})
```
## Execution parameters
Below are the parameters for the `executeRoutes` function along with their descriptions:
[route](#) `RouteResponse` `required`
This is a route object as produced by the `getRoutes` function.
[walletClient](#) `WalletClient` `required`
This is a Viem-compatible wallet client object which will be used for resolving onchain transactions such as swapping and bridging. See the [Viem docs](https://viem.sh/docs/clients/wallet) for more details.
# Installation
Source: https://docs.suave.money/suave.ag/sdk/install
To get started with the Suave SDK, follow these installation instructions.
The Suave Aggregator SDK will only function properly in a browser-like environment. You can use a library like [web3-mock](https://github.com/DePayFi/web3-mock) to simulate this in Node.js.
You will need to also have [viem](https://viem.sh/) installed to get started. To install everything with npm, use this command:
```
npm install --save @suave_money/sdk viem
```
# Request Routes & Quotes
Source: https://docs.suave.money/suave.ag/sdk/request
Prior to executing a swap or a bridge, you need to request the best route from our API
The Suave Aggregator SDK will only function properly in a browser-like environment. You can use a library like [web3-mock](https://github.com/DePayFi/web3-mock) to simulate this in Node.js.
Use the `getRoutes` function to fetch routes/quotes from the Sauve Aggregator API.
Here is a simple example of how to request routes to bridge [10 USDC](https://arbiscan.io/token/0xda10009cbd5d07dd0cecc66161fc93d7c9000da1) on Arbitrum to the maximum amount of [DAI](https://polygonscan.com/token/0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063) on Polygon.
```ts theme={null}
import { getRoutes, RouteResponse } from '@suave-money/sdk'
const routes: RouteResponse[] = await getRoutes({
inputAmount: '10000000', // 10 USDC
fromChainId: 42161, // Arbitrum
fromToken: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', // USDC on Arbitrum
toChainId: 137, // Polygon
toToken: '0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063' // DAI on Polygon
})
```
## Routes request parameters
Below are the parameters for the `getRoutes` function along with their descriptions:
[fromChainId](#) `number` `required`
The ID of the source chain.
| Chain Name | Chain ID |
| ---------- | -------- |
| Ethereum | 1 |
| Optimism | 10 |
| Polygon | 137 |
| Arbitrum | 42161 |
[fromTokenAddress](#) `string` `required`
The contract address of the token on the source chain. Ensure this address corresponds to the specified fromChainId.
[fromAmount](#) `string` `required`
The amount to be transferred from the source chain, specified in the smallest unit of the token (e.g., wei for ETH).
[fromAddress](#) `string` `optional`
The address from which the tokens are being transferred.
[toChainId](#) `number` `required`
The ID of the destination chain
| Chain Name | Chain ID |
| ---------- | -------- |
| Ethereum | 1 |
| Optimism | 10 |
| Polygon | 137 |
| Arbitrum | 42161 |
[toTokenAddress](#) `string` `required`
The contract address of the token on the destination chain. Ensure this address corresponds to the specified toChainId.