> For the complete documentation index, see [llms.txt](https://docs.entangle.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.entangle.fi/universal-interoperability-protocol/developer-guides/sdk-setup.md).

# SDK Setup

The SDK helps you interact with the messaging layer across chains. It handles functionality such as, fee estimation, message hashing, and network activity checks. The SDK is compatible whether you're working with EVM or Solana. It gives you the tools to simulate and prepare cross-chain messages with minimal setup. This guide will walk you through the setup process for the SDK.

The SDK provides fees functionalities that's used to calculate fees, check network activity, and calculate message hashes from source network transaction receipts. Below we go over examples and usage

{% hint style="info" %}
Reach out to us via our [contact page](https://entangle.zendesk.com/hc/en-us/requests/new) for suggestions or requests.
{% endhint %}

## Installation <a href="#installation" id="installation"></a>

Begin by installing the SDK in your project first. We'll be using NPM in this guide. Run the installation command below to get started.

```bash
npm install @entangle-labs/uip-sdk
```

## API

There are two main methods for estimation as shown below.

{% tabs %}
{% tab title="EVM" %}

```solidity
public async estimateExecutionWithGas({
  srcChainId: bigint,
  destChainId: bigint,
  gasLimit: bigint
})
```

{% endtab %}

{% tab title="Solana" %}

```rust
public async estimateExecutionSolana(
  input: SimulateExecuteLiteInput
)

export type SimulateExecuteLiteInput = {
  connection: Connection;
  payload: Buffer;
  srcChain: bigint;
  senderAddr: Buffer;
  destChain: bigint;
  destAddr: PublicKey;
  accounts: AccountMeta[];
  payerOverride?: PublicKey;
  computeUnits?: number;
};
```

{% endtab %}
{% endtabs %}

## Mode

By default, the SDK is configured for Mainnet usage. However, you can configure it to work for testnet like so.

{% tabs %}
{% tab title="Mainnet" %}

```typescript
const provider = new UIPProvider("<https://evm-testnet.entangle.fi>")
const feesEvm = new FeesEvm(provider)
feesEvm.mode = "mainnet"
feesEvm.EIBName = "eib"
```

{% endtab %}

{% tab title="Testnet" %}

```typescript
const provider = new UIPProvider("<https://json-rpc.entangle.fi>")
const feesEvm = new FeesEvm(provider)
feesEvm.mode = "testnet"
feesEvm.EIBName = "teib"
```

{% endtab %}
{% endtabs %}

## Network Configuration

SDK use public RPC providers by default. If you want to use your own&#x20;personal config, redefine config with.

```typescript
const feesSdkConfigured = new FeesEvm(provider, config as Chain[])
```

Where config is an array of `Chain` objects:

```typescript
{
  id: BigInt(11155111),
  name: "ethereum_sepolia",
  hexId: "0xAA36A7",
  type: "evm",
  mode: "testnet",
  rpcUrl: "<https://ethereum-sepolia-rpc.publicnode.com>",
  nativeCurrency: {
    name: "Sepolia Ether",
    symbol: "ETH",
    decimals: 18,
  },
  blockExplorerUrl: "<https://sepolia.etherscan.io>",
}
```

## Usage

{% tabs %}
{% tab title="EVM" %}

```typescript
import { FeesEvm, FeesSolana, UIPProvider } from "@entangle-labs/uip-sdk"

const provider = new UIPProvider("<https://json-rpc.entangle.fi>")
const feesEvm = new FeesEvm(provider)

async function getDstChainFee() {
  const fee = await feesSdk.estimateExecutionWithGas({
    srcChainId: 11155111n,
    destChainId: 33133n,
    gasLimit: 200000n,
  });
  console.log("Estimated price:", fee)
}
```

```typescript
  import { generateReceiptHash } from "@entangle-labs/uip-sdk"
  // ... get receipt

  const msgHash = await generateReceiptHash(BigInt(33133), receipt)
```

{% endtab %}

{% tab title="Solana" %}

```typescript
import { FeesSolana } from "@entangle-labs/uip-sdk"

const feesSolana = new FeesSolana()

fee = await feesSolana.estimateExecutionSolana({
  connection: new Connection(srcChain.rpcUrl),
  payload: Buffer.from(payloadOriginal),
  srcChain: BigInt(srcChainId),
  senderAddr: Buffer.from(senderContractAddr),
  destChain: BigInt(dstChainId),
  destAddr: new PublicKey(destAddr),
  accounts: [
    // Provide the accounts required for execution on the destination address
  ],
})
```

{% endtab %}
{% endtabs %}
