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

Reach out to us via our contact page for suggestions or requests.

Installation

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.

npm install @entangle-labs/uip-sdk

API

There are two main methods for estimation as shown below.

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

Mode

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

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

Network Configuration

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

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

Where config is an array of Chain objects:

{
  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

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)
}
  import { generateReceiptHash } from "@entangle-labs/uip-sdk"
  // ... get receipt

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

Last updated

Was this helpful?