> 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()
```

***

####
