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

@vessel-kit/blockchain-connection-string

v1.0.0

Published

Blockchain connection string is a way to pass connection information to a light-weight blockchain provider in a single string akin to database connection string.

Downloads

6

Readme

Blockchain Connection String

Blockchain connection string is a way to pass connection information to a light-weight blockchain provider in a single string akin to database connection string.

Specification

It is common to connect to blockchain node via API. With it come the following considerations:

  1. There are multiple blockchains, which is important for blockchain-agnostic applications.
  2. There are multiple transports: HTTP OpenRPC, WebSocket OpenRPC, gRPC, GraphQL.
  3. A transport might require its own set of additional properties, e.g. bearer token for Infura.
  4. Often an application requires different providers or transports based on environment: HTTP provider with private key while developing, WebSocket provider while in production.
  5. Often API endpoint comes as an environment variable as per The Twelve Factor App.

Often selection of blockchain connection mechanism is re-invented for every app. We strive to solve this by providing a universal connection string format, based on which an application could deterministically select an appropriate provider.

Blockchain connection string is based on URL specification defined in RFC 3986. The goal of blockchain connection string is to unify blockchain API connection across:

  • different blockchains,
  • different messaging protocols,
  • different transport protocols,
  • different key material.

Blockchain part helps to select appropriate connector in a blockchain-agnostic application. Transport and messaging protocols are present here separately to avoid ambiguity. GraphQL and OpenRPC messages could be transmitted over HTTP and WebSocket transports both.

Syntax

blockchain_connection_string = scheme ":" endpoint [ "?" options ]
scheme = known-transport | chain "+" messaging "+" transport
chain = scheme-part
transport = scheme-part
messaging = scheme-part
scheme-part = ALPHA *( ALPHA / DIGIT / "-" / "." )
endpoint = hier-part
options = query
known-transport = "http" | "https" | "ws" | "wss"

See RFC 3986 for definitions of hier-part and query.

Semantics

Each connection string starts with scheme, which contains three parts, separated by + sign:

  • chain identifies blockchain family, like eip155, bip122, cosmos, lip9, polkadot.
  • transport represents transport protocol, like grpc, http, or ws,
  • messaging represents messaging protocol, like graphql, openrpc.

To maintain compatibility with currently used HTTP API endpoints, known transport protocols could be used instead of full scheme.

endpoint is a usual host-port pair. options are connection-specific pairs of key-value elements, as in URL query.

Test Cases

Manually composed examples are below:

# Ethereum OpenRPC connection to Infura via HTTPS, read only
eip155+openrpc+https://mainnet.infura.io/
eip155+openrpc+https://mainnet.infura.io/

# Ethereum OpenRPC connection to Infura via WebSocket, using key material for signing
eip155+openrpc+wss://mainnet.infura.io?mnemonic=enemy boat gauge orphan column malbolge prepare cave only first limb garlic&path=m/44'/60'/0'/0/0

Usage

const connectionString = ConnectionString.build(`eip155+openrpc+https://mainnet.infura.io/?mnemonic=enemy boat gauge orphan column malbolge prepare cave only first limb garlic&path=m/44'/60'/0'/0/0`)
connectionString.chain #= eip155
connectionString.messagingProtocol #= openrpc
connectionString.transportProtocol #= https
connectionString.transport #= https://mainnet.infura.io/
connectionString.options #= {mnemonic: "enemy boat gauge orphan column malbolge prepare cave only first limb garlic", path: "m/44'/60'/0'/0/0"}