> For the complete documentation index, see [llms.txt](https://gasyard-1.gitbook.io/gasyard/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gasyard-1.gitbook.io/gasyard/sdk-implementation.md).

# SDK Implementation

### Installation

Install the Gasyard SDK via npm:

```sh
npm install gasyard-sdk
```

***

### **Initialization**

To use the SDK, import it and initialize with your API key:

```javascript
import { ConfigResponse, GasyardSDK } from 'gasyard-sdk';
const sdk = new GasyardSDK({
    apiKey: 'DEMO',});
```

#### **Need Help?**

If you're looking to integrate our API or SDK and need assistance, feel free to reach out on Telegram: [t.me/qimchi](https://t.me/qimchi).&#x20;

***

### **1. Get a Swap Quote**

Fetches a quote for token swaps between networks.

#### **Example Usage:**

```javascript
const getQuote = async () => {
  try {
    const quote = await sdk.getQuote({
      inputNetwork: 2,
      outputNetwork: 5,
      inputTokenAmount: "5000000000000000",
      outputTokenContract: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
    });
    console.log(quote);
  } catch (error) {
    console.error(error);
  }
};
getQuote();
```

***

### **2. Get Network Configuration**

Retrieves configuration details for a specified blockchain network.

#### **Example Usage:**

```javascript
const getConfig = async () => {
  try {
    const config = await sdk.getConfig({ chainId: 4 });
    console.log(config);
  } catch (error) {
    console.error(error);
  }
};
getConfig();
```

***

### **3. Check Transaction Status**

Checks the status of a transaction based on its hash.

#### **Example Usage:**

```javascript
const checkStatus = async () => {
  try {
    const status = await sdk.getStatus({
      sourceHash: "0x50aa2de06b9a386a6f87ac0c509a088240e129c71503e7c323e4e27f7fcaeec4"
    });
    console.log(status);
  } catch (error) {
    console.error(error);
  }
};
checkStatus();
```

***

### **4. Get Transaction History**

Fetches transaction history for a given address.

#### **Example Usage:**

```javascript
const getHistory = async () => {
  try {
    const history = await sdk.getHistory({
      inputAddress: "0xc5218F7e68f800c45c4BF49D87BE56b6a2692efB"
    });
    console.log(history);
  } catch (error) {
    console.error(error);
  }
};
getHistory();
```

***

### **5. Bridge Tokens**

Initiates a token bridging transaction between two networks.

#### **Example Usage:**

```javascript
import { ConfigResponse, GasyardSDK } from 'gasyard-sdk';
const sdk = new GasyardSDK({
    apiKey: 'DEMO',
});

const main = async () => {
    const networks = await sdk.getConfig({});

    const base = networks.find(el => el.networkName == "Base")
    const move = networks.find(el => el.networkName == "hyperliquid")
    const quote = await sdk.getQuote({
        inputNetwork: base as ConfigResponse,
        outputNetwork: move as ConfigResponse,
        inputTokenAmount: "50000000000000000",
        outputTokenContract: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
        inputTokenContract: "0x0000000000000000000000000000000000000000"
    })
    console.log(quote)

    const config = await sdk.getConfig({})
    console.log(config)

    const { transaction } = await sdk.bridge({
        sourceNetwork: base as ConfigResponse,
        destinationNetwork: move as ConfigResponse,
        sourceTokenAmount: "50000000000000000",
        destinationAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
        tokenOutAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
        tokenInAddress: "0x0000000000000000000000000000000000000000"
    })

    console.log(transaction)
    // use your signer provider to call the `transaction` object

}

main()
```

***

####


---

# 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://gasyard-1.gitbook.io/gasyard/sdk-implementation.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.
