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

bridge-sdk

v2.15.0

Published

bridge-sdk

Downloads

96

Readme

Horizon Bridge SDK

Install instructions

npm i bridge-sdk --save

How to use

1. Init SDK instance

const { BridgeSDK, TOKEN, EXCHANGE_MODE, STATUS } = require('bridge-sdk');
const configs = require('bridge-sdk/lib/configs');

const bridgeSDK = new BridgeSDK({ logLevel: 0 });

await bridgeSDK.init(configs.testnet);

You can set logLevel 0-2

0 - logs disabled
1 - only errors and success
2 - full log (errors, succees, info, panding, waiting etc)

You can use config.mainnet: Harmony mainnet <> Ethereum mainnet.

Or you can use config.testnet: Harmony testnet <> Ethereum Kovan testnet.

Also you can create config with your custom contracts and validators - like here https://github.com/harmony-one/ethhmy-bridge.sdk/blob/main/src/configs/mainnet.ts

2. Set user wallet (NodeJS mode)

For ONE -> ETH operation you need to add ONE wallet:

await bridgeSDK.addOneWallet('bff5443377958e48e5fcfeb92511ef3f007ac5dd0a926a60b61c55f63098897e');

For ETH -> ONE operation you need to add Ethereum wallet:

await bridgeSDK.addEthWallet('1111223395a5c3c1b08639b021f2b456d1f82e4bdd14310410dffb5f1277fe1b');

2.1. Set user wallet (Browser mode)

If you use Browser you can sign transactions with Metamask or OneWallet

Metamask:

bridgeSDK.setUseMetamask(true);

full example here https://github.com/harmony-one/ethhmy-bridge.sdk/blob/main/examples/eth_to_one-browser.js

OneWallet:

bridgeSDK.setUseOneWallet(true);

full example here https://github.com/harmony-one/ethhmy-bridge.sdk/blob/main/examples/eth_to_one-browser.js

MathWallet:

bridgeSDK.setUseMathWallet(true);

If you want to do operations in both directions (eth <> one) - you need to set both wallet (Metamask + OneWallet).

3. Send tokens

let oprationId;

try {
  await bridgeSDK.sendToken({
    type: EXCHANGE_MODE.ETH_TO_ONE,
    token: TOKEN.BUSD,
    amount: 0.01,
    oneAddress: 'one11234dzthq23n58h43gr4t52fa62rutx4s247sk',
    ethAddress: '0x12344Ab6773925122E389fE2684A9A938043f475',
  }, (id) => oprationId = id);
} catch (e) {
  console.log(e.message);
}

You don't need to do anything more. All other actions will be done automaticly. If you work in browser mode - sign transactions action also will be called automaticly. You need only to fetch and display operation status (step 4)

* if you want to send ERC20 token - you need to set token token: TOKEN.ERC20 and add one more param erc20Address: 0x...

* Use try-catch to catch error with reason message. Also you can set logLevel = 2 for better debugging (look at step 1).

4. Get operation details

const operation = await bridgeSDK.api.getOperation(operationId);

* Recommended to use this call in a cycle if you want to monitoring & display operation status (look at full example)

Eth -> One (full example)

https://github.com/harmony-one/ethhmy-bridge.sdk/blob/main/examples/eth_to_one-node.js

const { BridgeSDK, TOKEN, EXCHANGE_MODE, STATUS } = require('bridge-sdk');
const configs = require('bridge-sdk/lib/configs');

const operationCall = async () => {
    const bridgeSDK = new BridgeSDK({ logLevel: 2 }); // 2 - full logs, 1 - only success & errors, 0 - logs off

    await bridgeSDK.init(configs.testnet);

    await bridgeSDK.addEthWallet('cbcf3af28e37d8b69c4ea5856f2727f57ad01d3e86bec054d71fa83fc246f35b');

    let operationId;

    // display operation status
    let intervalId = setInterval(async () => {
        if (operationId) {
            const operation = await bridgeSDK.api.getOperation(operationId);

            /*
            console.log(operation.status);
            console.log(
              'Action: ',
              operation.actions.filter(a => a.status === STATUS.IN_PROGRESS)
            );
            */

            if (operation.status !== STATUS.IN_PROGRESS) {
                clearInterval(intervalId);
            }
        }
    }, 4000);

    try {
        await bridgeSDK.sendToken(
            {
                type: EXCHANGE_MODE.ETH_TO_ONE,
                token: TOKEN.BUSD,
                amount: 0.01,
                oneAddress: 'one1we0fmuz9wdncqljwkpgj79k49cp4jrt5hpy49j',
                ethAddress: '0xc491a4c5c762b9E9453dB0A9e6a4431057a5fE54',
            },
            id => (operationId = id)
        );
    } catch (e) {
        console.log('Error: ', e.message);
    }

    process.exit();
};

operationCall();

You can see more examples here

https://github.com/harmony-one/ethhmy-bridge.sdk/tree/main/examples

  • If you want to copy this this example sources to your project - you need to change:
const { BridgeSDK, TOKEN, EXCHANGE_MODE, STATUS } = require('..');
const configs = require('../lib/configs');

to

const { BridgeSDK, TOKEN, EXCHANGE_MODE, STATUS } = require('bridge-sdk');
const configs = require('bridge-sdk/lib/configs');

More API methods

getOperations

const operations = await bridgeSDK.api.getOperations({ size: 50, page: 0 });