> 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 **Multichain Bridge + DEX AI Aggregator** 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             |


---

# 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/go-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.
