> 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 WheelX AI-powered aggregation 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             |
