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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ctrl-tech/chains-evm

v2.0.25

Published

```typescript const ethereumManifest = { name: 'Ethereum', description: '', rpcURL: 'https://ethereum-mainnet.xdefiservices.com', chainSymbol: 'ETH', blockExplorerURL: 'https://etherscan.io', chainId: '1', chain: 'ethereum', decimals: 18,

Downloads

5

Readme

Manifest

const ethereumManifest = {
  name: 'Ethereum',
  description: '',
  rpcURL: 'https://ethereum-mainnet.xdefiservices.com',
  chainSymbol: 'ETH',
  blockExplorerURL: 'https://etherscan.io',
  chainId: '1',
  chain: 'ethereum',
  decimals: 18,
  feeGasStep: {
    high: 1.5,
    medium: 1.25,
    low: 1,
  },
  multicallContractAddress: '0xcA11bde05977b3631167028862bE2a173976CA11',
};
  • name: The name of the blockchain network, in this case, Ethereum. Uses only for display name to user
  • description: A brief description or additional information about the blockchain network.
  • rpcURL: The URL of the JSON-RPC endpoint for interacting with the blockchain. It provides access to various blockchain-related functionalities such as querying information, sending transactions, and executing smart contracts.
  • chainSymbol: The symbol used to represent the native cryptocurrency of the chain, which is Ether (ETH) in this case.
  • blockExplorerURL: The URL of a block explorer service specific to the Ethereum blockchain. Block explorers allow users to view details about blocks, transactions, addresses, and other blockchain-related data.
  • chainId: The unique identifier for the chain. It distinguishes Ethereum from other blockchains and is used in various contexts such as transaction signing and network communication.
  • chain: The name of the blockchain network. If you are using IndexerDataSource, it must be obtained from the registry.
  • decimals: The number of decimal places used to represent the smallest unit of native token. e.g. Ether (ETH) on the Ethereum blockchain. Ethereum uses 18 decimals, meaning that 1 Ether is represented by 10^18 Wei.
  • feeGasStep: An object containing gas fee steps for different transaction priority levels. Gas is the unit used to measure the computational work done by transactions on the network. The values provided represent multipliers applied to the base gas fee for each priority level (high, medium, low).

EVM specific fields:

  • multicallContractAddress: The address of a smart contract known as Multicall, which allows batching multiple Ethereum function calls into a single transaction. This can help reduce the number of individual transactions needed to fetch data from the Ethereum blockchain, improving efficiency and reducing costs.

Custom chain

To implement a custom chain, you need to pass a custom manifest to ChainDatasource, and the data will be retrieved directly from the blockchain. ChainDatasource is mandatory because IndexerDatasource does not have custom chain-specific methods.

Example with Goerli testnet chain:

The main difference between supported chains and custom chains:

  • Supported chains can use IndexerDataSource;
  • You have to provide your own manifest for custom chains.
import { EvmProvider } from '@ctrl-tech/chains-evm';

const provider = new EvmProvider(
  new EvmProvider.dataSourceList.dataSourceList({
    name: 'Goerli',
    description: '',
    rpcURL: 'https://eth-goerli.public.blastapi.io',
    chainSymbol: 'ETH',
    blockExplorerURL: 'https://goerli.etherscan.io',
    chainId: '5',
    chain: 'goerli',
    decimals: 18,
    feeGasStep: {
      high: 1.5,
      medium: 1.25,
      low: 1,
    },
  })
);

// The same as any other provider
const response = await provider.getBalance(
  '0x1234567890123456789012345678901234567890'
);
const data = await response.getData();

Usage ethers provides

The library allows to use the JsonRpcProvider methods of ethers.

Example using ethers provider

import { EvmProvider, IndexerDataSource } from '@ctrl-tech/chains-evm';

const provider = new EvmProvider(new IndexerDataSource(EVM_MANIFESTS.ethereum));

const etherProvider = provider.rpcProvider;
// Send raw message to the provider
const data = await etherProvider.send(method, params);