> For the complete documentation index, see [llms.txt](https://docs.wheelx.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wheelx.fi/sdk-and-widget/js-sdk.md).

# JavaScript SDK

Developers can use the **JavaScript SDK** to build decentralized applications (dApps) that interact with the **Multichain Bridge + DEX AI Aggregator** platform.

<https://github.com/wheelx-fi/wheelx-sdk/tree/main/typescript>

### Install

npm

```
npm install @wheelx/sdk ethers
```

yarn

```
yarn add @wheelx/sdk ethers
```

pnpm

```
pnpm add @wheelx/sdk ethers
```

### Quick Start

```
import { WheelXSDK, QuoteRequest } from '@wheelx/sdk';

const sdk = new WheelXSDK();

const quoteRequest: QuoteRequest = {
from_chain: 1,
to_chain: 1,
from_token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
to_token: '0xdAC17F958D2ee523a2206206994597C13D831ec7', // USDT
from_address: '0x742d35Cc6634C0532925a3b8Dc9F6A7c5D3a7C6a',
to_address: '0x742d35Cc6634C0532925a3b8Dc9F6A7c5D3a7C6a',
amount: 1000000,
slippage: 50,
};

const quote = await sdk.getQuote(quoteRequest);
console.log(`Quote received: ${quote.amount_out} tokens`);
console.log(`Request ID: ${quote.request_id}`);
```

### Browser Usage (MetaMask)

```
import { WheelXSDK, TransactionExecutor } from '@wheelx/sdk';
import { ethers } from 'ethers';

if (typeof window.ethereum !== 'undefined') {
const provider = new ethers.BrowserProvider(window.ethereum);
await window.ethereum.request({ method: 'eth_requestAccounts' });
const signer = await provider.getSigner();
const sdk = new WheelXSDK();
const executor = new TransactionExecutor(provider, signer);
const fromAddress = await signer.getAddress();

const quote = await sdk.getQuote({ ...quoteRequest, from_address: fromAddress });
const result = await executor.executeQuoteTransaction(quote.tx, fromAddress);
console.log(`Transaction sent: ${result.hash}`);
}
```

### API Reference

#### WheelXSDK

| Method                      | Description                       |
| --------------------------- | --------------------------------- |
| `new WheelXSDK(config?)`    | Create new SDK instance           |
| `getQuote(request)`         | Get a quote for token swap/bridge |
| `getOrderStatus(requestId)` | Get order status by request ID    |

#### TransactionExecutor

| Method                                        | Description                       |
| --------------------------------------------- | --------------------------------- |
| `buildTransaction(txData, fromAddr, config?)` | Build transaction from quote data |
| `signAndSendTransaction(tx)`                  | Sign and send transaction         |
| `executeQuoteTransaction(txData, fromAddr)`   | Build + sign + send in one call   |
| `waitForTransaction(txHash)`                  | Wait for confirmation             |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wheelx.fi/sdk-and-widget/js-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
