LogoLogo
  • Entangle
    • Overview
    • Security Audits
  • Universal Interoperability Protocol
    • Overview
    • Architecture
      • Scalability and Network Stability
        • L2 Utility Blockchains
        • Transmitter Groups
      • Security and Consensus Mechanism
      • Finality
      • Execution Latency
      • Compatibility and Interoperability
    • Developer Guides
      • Getting Started
      • Solidity
        • Simple Abstract Messenger Example
        • Deploying Your Custom EVM Protocol
        • Bridging Tokens with UIP
        • Become an EVM Transmitter
      • Solana
        • Simple Abstract Messenger Example
        • Deploying Your Custom Solana Protocol
        • Become a Solana Transmitter
      • Calculate Cross-Chain Transaction Cost
      • Customizable Message Transmission Options
      • How to Debug Sent Messages
      • SDK Setup
      • Revenue Sharing for Transmitters
      • How to Become a Super Transmitter
    • Endpoints
  • Universal Data Feeds
    • Overview
    • Architecture
      • Data Delivery Methods
        • Pull Model
        • Push Model
      • Oracle Contract & User Interaction
    • Developer Guides
      • Custom Data Feeds
      • Fetch Data via Pull Model (PAYG)
        • EVM Smart Contracts
        • Solana Smart Contracts
      • Fetch Data via Pull Model (Subscriptions)
        • EVM Smart Contracts
        • Solana Smart Contracts
      • Fetch Data via Push Model
        • EVM Smart Contracts
        • Solana Smart Contracts
    • User Guides
      • Accessing Feeds
      • Subscribe to a Data Feed
      • Check Subscription
      • Manage Subscription
      • Renew Subscription
    • Data Endpoints
  • Universal Token Standard
    • Overview
    • Architecture
      • Fee Components
    • Developer Guides
      • Manual Deploy
        • Token Deployment Types
        • Create a Custom Token
        • Factory Blueprint Deployment
        • Examples
          • Initial Setup
          • UTS Connector
            • Mint & Burn Connector Scheme
            • Lock & Unlock Connector Scheme
            • Connector Over Native Currency
          • UTS Token
            • Simple Token
            • Token with Messages
      • Bridge SDK
      • Token Verification
      • Fees Calculation & Gas Estimation Logic
      • Estimations
    • User Guides
      • Launch Universal Token
      • Create a Liquidity Pool
      • Expand Existing Token
      • Transfer Liquidity to Connector
      • Bridging
    • Contract Addresses
  • Entangle Interoperable Blockchain
    • Overview
    • Architecture
    • Developer Guides
      • Set up a Validator Node
      • Delegating to Validators
      • Undelegating from Validators
      • Supported Accounts
  • More
    • Media Kit
    • FAQ
    • Report an Issue
    • Become a Partner
Powered by GitBook
On this page
  • Installation
  • API
  • Mode
  • Network Configuration
  • Usage

Was this helpful?

Export as PDF
  1. Universal Interoperability Protocol
  2. Developer Guides

SDK Setup

PreviousHow to Debug Sent MessagesNextRevenue Sharing for Transmitters

Last updated 26 days ago

Was this helpful?

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 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
})
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;
};

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"
const provider = new UIPProvider("<https://json-rpc.entangle.fi>")
const feesEvm = new FeesEvm(provider)
feesEvm.mode = "testnet"
feesEvm.EIBName = "teib"

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)
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
  ],
})
contact page