npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@balancednetwork/intents-sdk

v1.0.0

Published

Balanced Network Intents SDK

Readme

Balanced Intent Solver SDK (Alpha)

Balanced Intent Solver SDK provides abstractions to assist you with interacting with the cross-chain Intent Smart Contracts and Solver.

Note SDK is currently in alpha testing stage and is subject to change!

Installation

NPM

Installing through npm:

npm i --save @balancednetwork/intents-sdk

NOTE Package is not yet published to the npm registry!!!

Local

Package can be locally installed by following this steps:

  1. Clone this repository to your local machine.
  2. cd into repository folder location.
  3. Execute npm install command in your CLI to install dependencies.
  4. Execute npm run build to build the package.
  5. In your app repository package.json file, define dependency named "@balancednetwork/intents-sdk" under "dependencies". Instead of version define absolute path to your SDK repository "file:<sdk-repository-path>" (e.g. "file:/Users/dev/balanced-solver-sdk"). Full example: "@balancednetwork/intents-sdk": "file:/Users/dev/balanced-solver-sdk".

Local Development

How to setup local development

  1. Clone repository.
  2. Make sure you have Node.js v18+ and corresponding npm installed on your system.
  3. Execute npm install command in your CLI to install dependencies.
  4. Make code changes.
    1. Do not forget to export TS files in same folder index.ts.
    2. Always import files using .js postfix.
  5. Before commiting execute npm run prepublishOnly in order to verify build, format and exports.

Intent Solver Endpoints

Current Intent Solver API endpoints:

  • Production (mainnet): "https://solver.iconblockchain.xyz"
  • Staging (mainnet): "https://staging-solver.iconblockchain.xyz"

Note Staging endpoint contains features to be potentially released and is subject to frequent change!

Load SDK Config

SDK includes predefined configurations of supported chains, tokens and other relevant information for the client to consume.

import { ChainName, ChainConfig, chainConfig, Token, IntentService } from "@balancednetwork/intents-sdk"

// instantiate intent service with config
const intentService = new IntentService({
  solverApiEndpoint: "https://solver.iconblockchain.xyz",
})

// all supported Intent chains
const supportedChains: ChainName[] = intentService.getSupportedChains()

// retrieve arbitrum chain config
const arbChainConfig: EvmChainConfig = intentService.getChainConfig("arb")

// example of how to construct token per chain map using supported chains array
const supportedTokensPerChain: Map<ChainName, Token[]> = new Map(
  supportedChains.map((chain) => {
    return [chain, intentService.getChainConfig(chain).supportedTokens]
  }),
)

// example of how to construct chain name to chain config map
const chainConfigs: Map<ChainName, ChainConfig> = new Map(
  supportedChains.map((chain) => {
    return [chain, intentService.getChainConfig(chain)]
  }),
)

Request a Quote

Requesting a quote should require you to just consume user input amount and converting it to the appropriate token amount (scaled by token decimals). All the required configurations (chain id [nid], token decimals and address) should be loaded as described in Load SDK Config.

import { IntentService } from "@balancednetwork/intents-sdk"

const intentService = new IntentService({
  solverApiEndpoint: "https://solver.iconblockchain.xyz",
})

const quoteResult = await intentService.getQuote({
  token_src: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
  token_src_blockchain_id: "0xa4b1.arbitrum",
  token_dst: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
  token_dst_blockchain_id: "sui",
  src_amount: 100000000000000000n,
})

/**
 * Example response (quoteResult)
 * {
 *   "ok": true,
 *   "value": {
 *      "output": {
 *        "expected_output":"1000000000000", // to be used in create intent order as toAmount
 *        "uuid":"e2795d2c-14a5-4d18-9be6-a257d7c9d274" // to be used in create intent order as quote_uuid
 *      }
 *   }
 * }
 */

Initialising Providers

SDK abstracts away the wallet and public RPC clients using ChainProviderType TS type which can be one of the following:

  • EvmProvider: Provider used for EVM type chains (ETH, BSC, etc..). Implemented using viem.
  • SuiProvider: Provider used for SUI type chains (SUI). Implemented using @mysten/sui and @mysten/wallet-standard.

Optionally, you can supply EVM providers (wallet and public clients) yourself (see EvmInitializedConfig). SUI accepts only initialized Wallet, Account and Client.

Providers are used to request wallet actions (prompts wallet extension) and make RPC calls to the RPC nodes.

EVM Provider example:

import { EvmProvider } from "@balancednetwork/intents-sdk"

// NOTE: user address should be provided by application when user connects wallet
const evmProvider = new EvmProvider({
  userAddress: "0x601020c5797Cdd34f64476b9bf887a353150Cb9a",
  chain: "arb",
  provider: (window as any).ethereum,
})

SUI Provider example (uses SUI dApp Kit:

import { SuiProvider } from "@balancednetwork/intents-sdk"
import { useCurrentWallet, useCurrentAccount } from "@mysten/dapp-kit"

const account = useCurrentAccount()
const { currentWallet, connectionStatus } = useCurrentWallet()

// check that wallet is connected and account is defined
if (connectionStatus === "connected" && account) {
  const suiProvider = new SuiProvider({ wallet, account, client })
} else {
  throw new Error("Wallet or Account undefined. Please connect wallet and select account.")
}

Create Intent Order

Creating Intent Order requires creating provider for the chain that intent is going to be created on (fromChain).

Example for ARB -> SUI Intent Order:

import { IntentService, EvmProvider, CreateIntentOrderPayload, IntentStatusCode } from "@balancednetwork/intents-sdk"

// instantiate intent service with config
const intentService = new IntentService({
  solverApiEndpoint: "https://solver.iconblockchain.xyz",
})

// create EVM provider because "arb" is of ChainType "evm" (defined in ChainConfig type - see section Load SDK Config)
// NOTE: window can only be accessed client side (browser)
const evmProvider = new EvmProvider({
  userAddress: "0x601020c5797Cdd34f64476b9bf887a353150Cb9a",
  chain: "arb",
  provider: (window as any).ethereum,
})

const intentOrderPayload: CreateIntentOrderPayload = {
  quote_uuid: "a0dd7652-b360-4123-ab2d-78cfbcd20c6b",
  fromAddress: "0x601020c5797Cdd34f64476b9bf887a353150Cb9a", // address we are sending funds from (fromChain)
  toAddress: "0x81600ec58a2efd97f41380370cddf25b7a416d03ee081552becfa9710ea30878", // destination address where funds are transfered to (toChain)
  fromChain: "arb", // ChainName
  toChain: "sui", // ChainName
  token: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
  amount: BigInt("100000000000000000"),
  toToken: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
  toAmount: BigInt("1000000000000"),
} as const

// checks if token transfer amount is approved (required for EVM, can be skipped for SUI as it defaults to true)
const isAllowanceValid = await intentService.isAllowanceValid(intentOrderPayload, evmProvider)

if (isAllowanceValid.ok) {
  if (!isAllowanceValid.value) {
    // allowance invalid, prompt approval
    const approvalResult = await intentService.approve(
      "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
      BigInt("100000000000000000"),
      intentService.getChainConfig("arb").intentContract,
      evmProvider,
    )

    if (approvalResult.ok) {
      const executionResult = await intentService.executeIntentOrder(intentOrderPayload, evmProvider)

      if (executionResult.ok) {
        const intentStatus = await intentService.getStatus({
          task_id: executionResult.value.task_id,
        })

        if (intentStatus.ok) {
          console.log(intentStatus)

          /**
           * Example status
           * {
           *   "ok": true,
           *   "value": {
           *      "output": {
           *        "status":3, // use IntentStatusCode to map status code
           *        "tx_hash":"0xabcdefasdasdsafssadasdsadsadasdsadasdsadsa"
           *      }
           *   }
           * }
           */
        } else {
          // handle error
        }
      } else {
        // handle error
      }
    } else {
      // handle error
    }
  } else {
    // allowance is valid

    const executionResult = await intentService.executeIntentOrder(intentOrderPayload, evmProvider)
    // ...rest of result check and status check logic as above
  }
} else {
  // handle error
}

Cancel Intent Order

Active Intent Order can be cancelled using order ID obtained as explained in Get Intent Order.

Example cancel order:

import { IntentService, SwapOrder, EvmProvider } from "@balancednetwork/intents-sdk"

// instantiate intent service with config
const intentService = new IntentService({
  solverApiEndpoint: "https://solver.iconblockchain.xyz",
})

const evmProvider = new EvmProvider({
   userAddress: "0x601020c5797Cdd34f64476b9bf887a353150Cb9a",
   chain: "arb",
   provider: (window as any).ethereum
})
const intentOrder: Result<SwapOrder> = await intentService.getOrder(
  "0xabcdefasdasdsafssadasdsadsadasdsadasdsadsa",
  intentService.getChainConfig("arb").intentContract,
  evmProvider,
)

if (intentOrder.ok) {
   const cancelResult: Result<string> = await intentService.cancelIntentOrder(
      intentOrder.value.id,
      "arb",
      evmProvider,
   )

   if (cancelResult.ok) {
      const txHash = cancelResult.value
      ..
   } else {
      // handle error
   }
} else {
   // handle error
}

Get Intent Order

After the Intent order is created (executeIntentOrder), the resulting txHash can be used to query created on-chain order data. Intent order id is assigned as a part of tx execution, thus if you want to grab an actual order id to be potentially canceled in future you should invoke intentService.getOrder(..) function.

Example get order:

import { IntentService, SwapOrder, EvmProvider } from "@balancednetwork/intents-sdk"

// instantiate intent service with config
const intentService = new IntentService({
  solverApiEndpoint: "https://solver.iconblockchain.xyz",
})

const evmProvider = new EvmProvider({
  userAddress: "0x601020c5797Cdd34f64476b9bf887a353150Cb9a",
  chain: "arb",
  provider: (window as any).ethereum,
})
const intentOrder: Result<SwapOrder> = await intentService.getOrder(
  "0xabcdefasdasdsafssadasdsadsadasdsadasdsadsa",
  intentService.getChainConfig("arb").intentContract,
  evmProvider,
)

Get Intent Status

After Intent Order is created, the resulting task_id can be used to query the status of the task.

Example status check:

import { IntentService } from "@balancednetwork/intents-sdk"

// instantiate intent service with config
const intentService = new IntentService({
  solverApiEndpoint: "https://solver.iconblockchain.xyz",
})

const intentStatus = await intentService.getStatus({
  task_id: "a0dd7652-b360-4123-ab2d-78cfbcd20c6b",
})

/**
 * Example intentStatus response
 * {
 *   "ok": true,
 *   "value": {
 *      "output": {
 *        "status":3, // use IntentStatusCode to map status code
 *        "tx_hash":"0xabcdefasdasdsafssadasdsadsadasdsadasdsadsa"
 *      }
 *   }
 * }
 */