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

intents.js

v1.6.2

Published

Abstract State Change Expression Library

Readme

Intents.js SDK

NPM Version codecov

Supported Chains

  • [x] Ethereum
  • [x] Binance
  • [x] Polygon

Getting Started

You can find the full intents.js documentation at docs.borsa.network

1. Installation

Install intents.js using npm:

npm install intents.js

2. Setup

You can set up intents.js using either a private key or Web3Auth for authentication:

Option 1: Using Private Key

import { Account, IntentBuilder, PROJECTS, CHAINS, toBigInt, amountToBigInt, Asset, Stake } from 'intents.js';
import { ethers } from 'ethers';

const chainConfigs = {
  1: {
    rpcUrl: 'YOUR_ETH_RPC_URL',
    bundlerUrl: 'https://eth.bundler.borsa.network',
  },
  56: {
    rpcUrl: 'YOUR_BNB_RPC_URL',
    bundlerUrl: 'https://bsc.bundler.borsa.network',
  },
  137: {
    rpcUrl: 'YOUR_POLYGON_RPC_URL',
    bundlerUrl: 'https://polygon.bundler.borsa.network',
  },
};

const intentBuilder = await IntentBuilder.createInstance(chainConfigs);
const signer = new ethers.Wallet('your private key');
const account = await Account.createInstance(signer, chainConfigs);

Option 2: Using Web3Auth

import { Web3Auth } from '@web3auth/web3auth';
import { Account, IntentBuilder } from 'intents.js';

const web3Auth = new Web3Auth({
  clientId: 'YOUR_WEB3AUTH_CLIENT_ID', // Replace with your client ID
  chainConfig: {
    chainId: '0x1', // Ethereum Mainnet
    rpcUrl: 'https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID',
  },
});

const web3authProvider = await web3Auth.connectWith('google');

const ethersProvider = new ethers.BrowserProvider(web3authProvider as any);
const web3AuthSigner = ethersProvider.getSigner();

const accountInstance = await Account.createInstance(web3AuthSigner, chainConfigs);

const chainConfigs = {
  1: {
    rpcUrl: 'YOUR_ETH_RPC_URL',
    bundlerUrl: 'https://eth.bundler.borsa.network',
  },
};

const intentBuilder = await IntentBuilder.createInstance(chainConfigs);
const account = await Account.createInstance(web3AuthSigner, chainConfigs);

You can extend this to use any other provider with ethers and this sdk too

3. Create an Intent

An intent represents a desired outcome. The intent structure consists of two symmetric source and destination states.

In this example, we are using funds from AAVE (BNB Chain) to stake on Lido (Ethereum):

const usdtAddress = '0xdac17f958d2ee523a2206206994597c13d831ec7';
const ethAddress = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';

const from = new Loan({
  address: PROJECTS.Aave,
  amount: amountToBigInt(244.7, 18),
  chainId: toBigInt(CHAINS.BNBChain),
  asset: usdtAddress,
});

const to = new Stake({
  amount: amountToBigInt(0.1, 18),
  address: PROJECTS.Lido,
  chainId: toBigInt(CHAINS.Ethereum),
  asset: ethAddress,
});

4. Execute the Intent

Simply provide the source and destination states along with the associated account.

The execute() function will then wrap the intent as an ERC-4337 userOp and submit it to the Borsa network.

const solvedHash = await intentBuilder.execute(from, to, account);

4b. Deposit resulting tokens from intent execution into another address

When staking, supplying loan or swapping tokens, you can deposit the swapped tokens to be deposited into another address instead of the address that executed the tx.

The execute takes an optional config object as below

const execOption: ExecutionOptions = {
  sourceChainId: 888,
  recipient: '0xAddress',
};
const solvedHash = await intentBuilder.execute(source, destination, account, execOption);

4c. Cross chain

import { CrossChainBuilder } from 'intents.js';

const crossChainBuilder = await CrossChainBuilder.createInstance(chainConfigs);

const result = await crossChainBuilder.swapCrossChain(source, destination, account, 1, 56);

5. Fetch the Onchain Transaction Receipt

After the transaction is executed, you can fetch the receipt:

const receipt = await intentBuilder.getReceipt(1, solvedHash);

const txHash = receipt.result.receipt.transactionHash;

console.log(
  `View your tx onchain using any explorer:
   Hash: ${txHash}
   tx link: https://etherscan.io/tx/${txHash}`,
);

Utility Functions

The SDK offers several utility functions for managing conversions and amounts:

  • toBigInt(value: bigint | number): ProtoBigInt
  • floatToWei(amount: number): bigint
  • weiToFloat(wei: bigint): number
  • tokenToFloat(amount: bigint, decimals: number): number
  • floatToToken(amount: number, decimals: number): bigint
  • amountToBigInt(amount: number, decimal: number): ProtoBigInt

Sending a conventional userOp

The Borsa network is fully compatible with the ERC-4337 standard and can operate as a bundler for standard userOps.

await intentBuilder.executeStandardUserOps(account, ChainID, {
  calldata: '0x', // optional
  callGasLimit: CALL_GAS_LIMIT,
  maxFeePerGas: MAX_FEE_PER_GAS,
  maxPriorityFeePerGas: MAX_PRIORITY_FEE_PER_GAS,
  verificationGasLimit: VERIFICATION_GAS_LIMIT,
});

Contributing

Contributions to intents.js are welcome! Please refer to our contributing guidelines for more information.

License

This project is licensed under the MIT License.