> 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/go-sdk.md).

# Go SDK

Developers can use the **Go SDK** to build backend services and microservices that interact with the WheelX AI-powered aggregation platform.

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

### Install

```
go get github.com/wheelx-fi/wheelx-sdk/go/wheelx
```

Requires [go-ethereum](https://github.com/ethereum/go-ethereum) for transaction execution:

```
go get github.com/ethereum/go-ethereum
```

### Quick Start

```
package main

import (
"context"
"fmt"
"log"

"github.com/wheelx-fi/wheelx-sdk/go/wheelx"
)

func main() {
// Initialize SDK
sdk := wheelx.NewWheelXSDK("")

// Create quote request
req := wheelx.QuoteRequest{
FromChain:   1,
ToChain:     1,
FromToken:   "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
ToToken:     "0xdAC17F958D2ee523a2206206994597C13D831ec7",   // USDT
FromAddress: "0x742d35Cc6634C0532925a3b8Dc9F6A7c5D3a7C6a",
ToAddress:   "0x742d35Cc6634C0532925a3b8Dc9F6A7c5D3a7C6a",
Amount:      1000000, // 1 USDC (6 decimals)
Slippage:    &[]int{50}[0],
}

// Get quote
ctx := context.Background()
quote, err := sdk.GetQuote(ctx, req)
if err != nil {
log.Fatalf("Failed to get quote: %v", err)
}

fmt.Printf("Quote received: %s tokens\n", quote.AmountOut)
fmt.Printf("Request ID: %s\n", quote.RequestId)
}
```

### Transaction Execution

```
import (
"github.com/ethereum/go-ethereum/common"
)

// Initialize executor
executor, err := wheelx.NewTransactionExecutor("https://mainnet.infura.io/v3/YOUR_PROJECT_ID")
if err != nil {
log.Fatalf("Failed to create executor: %v", err)
}

// Build and send EIP-1559 transaction
fromAddress := common.HexToAddress(req.FromAddress)
tx, err := executor.BuildEIP1559Transaction(ctx, quote.Tx, fromAddress)
if err != nil {
log.Fatalf("Failed to build transaction: %v", err)
}

txHash, err := executor.SignAndSendTransaction(ctx, tx, "YOUR_PRIVATE_KEY")
if err != nil {
log.Fatalf("Failed to send transaction: %v", err)
}
fmt.Printf("Transaction sent: %s\n", txHash.Hex())
```

### API Reference

#### WheelXSDK

| Method                                                   | Description                       |
| -------------------------------------------------------- | --------------------------------- |
| `NewWheelXSDK(baseURL string)`                           | Create new SDK instance           |
| `GetQuote(ctx, req) (*QuoteResponse, error)`             | Get a quote for token swap/bridge |
| `GetOrderStatus(ctx, requestID) (*OrderResponse, error)` | Get order status by request ID    |

#### TransactionExecutor

| Method                                              | Description                       |
| --------------------------------------------------- | --------------------------------- |
| `NewTransactionExecutor(rpcURL string)`             | Create executor with RPC endpoint |
| `BuildTransaction(ctx, txData, fromAddress)`        | Build legacy transaction          |
| `BuildEIP1559Transaction(ctx, txData, fromAddress)` | Build EIP-1559 transaction        |
| `SignAndSendTransaction(ctx, tx, privateKey)`       | Sign and send transaction         |
| `WaitForTransaction(ctx, txHash)`                   | Wait for confirmation             |
