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

web3protocol

v0.6.1

Published

Parse and execute ERC-6860 web3:// URLs

Downloads

42

Readme

web3protocol

npm version

Parse and execute ERC-6860 / ERC-4804 web3:// protocol URLs. Used by EVM Browser to browse web3:// on-chain websites.

Usage

import { Client } from 'web3protocol';
import { getDefaultChainList } from 'web3protocol/chains';

// Get a prepared chain list that you can optionally alter, or provide your own
let chainList = getDefaultChainList()

// Configure a client with these chains definitions
let web3Client = new Client(chainList)

let fetchedWeb3Url = await web3Client.fetchUrl("web3://0xA5aFC9fE76a28fB12C60954Ed6e2e5f8ceF64Ff2/resourceName")
// Returns:
// fetchedWeb3Url.httpCode == 200
// fetchedWeb3Url.httpHeaders == {}
// fetchedWeb3Url.output == ReadableStream returning bytes [ 63, 63, 63 ]

Fetch a web3:// URL, get an HTTP status code, HTTP response headers and a ReadableStream.

getDefaultChainList() is provided as a quick way to launch (mix of RPC URLs provided by the Viem.sh library and the chainid.network website), but be aware this could sometimes get out of date.

Apps using web3protocol : web3curl, a simple CURL-like app; EVM Browser, a web3:// electron-based web browser.

Supported standards

Implemented features

  • ERC-6860 (draft) : the base web3:// protocol with auto and manual mode, basic ENS support. This updates ERC-4804 (final) with clarifications, small fixes and changes.
  • ERC-6821 (draft) : ENS resolution : support for the contentcontract TXT field to point to a contract in another chain
  • ERC-6944 (draft) / ERC-5219 (final) : New mode offloading some parsing processing on the browser side
  • ERC-7617 (draft): Add chunk support in ERC-6944 resource request mode
  • ERC-7618 (draft): Add Content-encoding handling in ERC-6944 resource request mode
  • Not standard : Linagee .og domain names

Partially implemented features

  • ERC-7087 (draft) : Auto mode : Add MIME type support (dataURLs not supported yet)

Options

The client takes the following options:

let web3Client = new Client(chainList, {
  multipleRpcMode: "fallback",
  domainNameResolverCache: {
    maxEntries: 256,
    maxAgeSeconds: 30 * 60,
  },
  resolveModeDeterminatorCache: {
    maxEntries: 256,
    maxAgeSeconds: 30 * 60,
  },
})
  • multipleRpcMode (fallback or parallel) : If a chain have multiple RPC configured, by default the fallback mode is used (first one is used, then if failure, the second one, and so on). In the parallel mode, a call is sent simultaneously to all RPCs, and the first one answering is used.
  • domainNameResolverCache: An object of options for domain name resolution caching. May be null to use default options. Otherwise, the object may specify:
    • maxEntries: The maximum number of cached entries. After this, the least-recently-used entry is dropped. Use zero to disable caching.
    • maxAgeSeconds: The maximum number of seconds before a resolution result is no longer considered valid.
  • resolveModeDeterminatorCache: An object of options for resolve mode determination caching. May be null to use default options. Otherwise, the object may specify:
    • maxEntries: The maximum number of cached entries. After this, the least-recently-used entry is dropped. Use zero to disable caching.
    • maxAgeSeconds: The maximum number of seconds before a determination result is no longer considered valid.

If you want to edit the chain list from getDefaultChainList(), to, for example, edit the RPCs of a chain, edit the chain list before giving it to the client :

let chainList = getDefaultChainList()
chainList.find(chain => chain.id == <chainId>).rpcUrls = ['https://<yourRPC>', 'https://<yourSecondRPC>', ...];
let web3Client = new Client(chainList)

Testing

Web3:// test files are located in their own git repository and are imported as a git submodule. After cloning, please run git submodule init and then git submodule update.

Testing is then launched with yarn test