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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@orbiter-finance/explore-link

v0.0.12

Published

JavaScript library for Orbiter Finance Explore Link

Readme

ExploreLinkProvider

The ExploreLinkProvider class is designed to provide convenient links for blockchain explorers. This class can fetch and manage blockchain configuration data (either locally or remotely via API) and generate links for accounts, tokens, and transactions across different blockchain networks. It supports both mainnet and testnet environments.

Features

  • Load Blockchain Configurations: Load chain configurations either from local JSON files or remotely via the Orbiter API.
  • Explorer Link Generation: Generate explorer links for accounts, tokens, and transactions based on chain configuration.
  • Dynamic Configuration Management: Add or update blockchain configurations dynamically at runtime.

Installation

To install and use this package, run:

npm install

Usage

1. Import the Module

import ExploreLinkProvider, { Endpoint } from './ExploreLinkProvider';

2. Initialize the Provider

You can initialize the ExploreLinkProvider by passing the appropriate endpoint for either mainnet or testnet:

const exploreProvider = new ExploreLinkProvider(Endpoint.mainnet);

3. Generate Explorer Links

Once initialized, you can generate explorer links for accounts, tokens, and transactions by providing the respective blockchain chainId and values:

Get Account Link

const accountLink = await exploreProvider.getAccountLink('1', '0x123...abc');
console.log(accountLink); // Returns the explorer URL for the account

Get Token Link

const tokenLink = await exploreProvider.getTokenLink('1', '0x456...def');
console.log(tokenLink); // Returns the explorer URL for the token

Get Transaction Link

const txLink = await exploreProvider.getTransactionLink('1', '0x789...ghi');
console.log(txLink); // Returns the explorer URL for the transaction

4. Add or Update Blockchain Configuration

You can dynamically add a new chain configuration or update an existing one:

const newChainConfig: ChainConfig = {
  chainId: '100',
  name: 'NewChain',
  explorers: [
    {
      url: 'https://newchain.explorer.io',
      name: 'NewChain Explorer',
      standard: 'EIP3091',
    },
  ],
};

await exploreProvider.addBlockchain('100', newChainConfig);

Configuration

The ExploreLinkProvider uses two primary sources for blockchain configurations:

  • Local JSON Files: Predefined configurations for mainnet and testnet chains.
    • chains.json: Mainnet chain configurations
    • testnet.json: Testnet chain configurations

ExplorerFactory

ExploreLinkProvider uses an ExplorerFactory to create explorer objects based on the chain configuration. These explorers provide methods to generate the appropriate links for accounts, tokens, and transactions.

Example ExplorerFactory Usage

import { ExplorerFactory } from './explorer.factory';

const config = {
  url: 'https://etherscan.io',
  name: 'Etherscan',
  standard: 'EIP3091',
};
const explorer = ExplorerFactory.createExplorer(config);

const accountLink = explorer.getAccountLink('0x123...abc');
console.log(accountLink); // Generates the Etherscan account URL

Error Handling

If no explorers are available for a given chain, the ExploreLinkProvider will throw an error:

try {
  const accountLink = await exploreProvider.getAccountLink('999', '0x123...abc');
} catch (error) {
  console.error(error.message); // "No explorers available for chain: 999"
}

API Endpoints

The ExploreLinkProvider supports two API endpoints, represented by the Endpoint enum:

  • Endpoint.mainnet: Mainnet chains
  • Endpoint.testnet: Testnet chains

ChainConfig Interface

A ChainConfig represents the configuration for a blockchain network, including its explorers:

export interface ChainConfig {
  chainId: string;
  name: string;
  explorers: {
    url: string;
    name: string;
    standard: string;
  }[];
}

Development

Clone the repository:

git clone https://github.com/your-repo/explore-link-provider.git
cd explore-link-provider

Install dependencies:

npm install

Run tests:

npm test

License

This project is licensed under the MIT License.