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

tezos-uri

v2.0.1

Published

JavaScript library that decodes, encodes and validates Tezos payment requests.

Readme

tezos-uri

This package provides a JavaScript implementation of the Tezos URI standard. It is written in ReasonML and compiled to JS.

Currently, when users try to interact with a DApp, they have to copy-paste transaction parameters into their wallet by hand. This interaction is far from frictionless and we've built this package to fix that.

The HTML documentation is here. A step-by-step guide is here.

Quick Start

Use with JavaScript with NPM

First install the package from NPM by running the following command:

npm install tezos-uri

Then, you can import it into your project:

ES-style import with a bundler (e.g. webpack)

import { encodeMainnet, decodeMainnet } from "tezos-uri";

Please note that we don't actually distribute an ES module and this works thanks to the bundler processing your project before deployment. It does not work directly in the browser.

NodeJS require

const tezosUri = require("tezos-uri");

Use with JavaScript without NPM

Simply embed a script tag in your HTML:

<script src="https://unpkg.com/[email protected]/bin/tezosUri.js" integrity="sha384-jSmeZaZ9MPGFKDxjkpJNppKJuWY0yQL/n/mftVXZt+QJp1JAS6E6f39ZNzSxX0Cz" crossorigin="anonymous"></script>

Use with ReasonML

First install the package from NPM by running the following command:

npm install tezos-uri

Then add it to your dependencies in bsconfig.json:

{
  ...
  "bs-dependencies": ["tezos-uri"]
}

The project will be available under the TezosUri namespace.

Reading the code

The code is written in ReasonML, a dialect of OCaml, and then compiled to JavaScript. It's easier to read in an editor that supports the language , such as VSCode (using the reason-vscode extension).

You can read the JS files after you build the project, or you can just use the tezosUri-js branch

JavaScript API Reference

Encode API

Validates and encodes a JSON payment request and returns a Tezos URI. Raises an exception on invalid input.

There are some examples of the JSON object in the section below. The exact specification for the payment request JSON is here.

/**
 * @description Validates and encodes a JSON payment request and returns
 *   a Tezos Mainnet URI. Raises an exception on invalid input.
 * @param {Array<Request>} input JSON payment request
 * @returns {string} Tezos Mainnet URI
 */
export declare function encodeMainnet(input: Array<Request>): string;

/**
 * @description Validates and encodes a JSON payment request and returns
 *   a Tezos Testnet URI. Raises an exception on invalid input.
 * @param {Array<Request>} input JSON payment request
 * @returns {string} Tezos Testnet URI
 */
export declare function encodeTestnet(input: Array<Request>): string;

Decode API

Decodes and validates a Tezos URI and returns the resulting JSON payment request. Raises an exception when the request is invalid, or when the URI does not match the expected network.

/**
 * @description Decodes and validates a Tezos URI and returns a resulting
 *   payment request JSON. Raises an exception when the request is invalid,
 *   or when the URI is not a Tezos Mainnet URI.
 * @param {string} uri Tezos Mainnet URI
 * @returns {Array<Request>} payment request JSON
 */
export declare function decodeMainnet(uri: string): Array<Request>;

/**
 * @description Decodes and validates a Tezos URI and returns a resulting
 *   payment request JSON. Raises an exception when the request is invalid,
 *   or when the URI is not a Tezos Testnet URI.
 * @param {string} uri Tezos Testnet URI
 * @returns {Array<Request>} payment request JSON
 */
export declare function decodeTestnet(uri: string): Array<Request>;

JavaScript Examples

Encode

import { encodeMainnet } from "tezos-uri";

const operation = {
  kind: "transaction",
  amount: "100000",
  destination: "tz1NAP47ubff4JDLJ94UcwEs66dDDAJGRDwN"
};

const link = encodeMainnet([{ content: operation }]);

Decode

import { decodeMainnet } from "tezos-uri";

const decoded = decodeMainnet(link);

ReasonML API Reference

Encode API

Validates and encodes a JSON payment request and returns a Tezos URI. Raises an exception on invalid input.

There are some examples of the JSON object in the section below. The exact specification for the payment request JSON is here.

let mainnet: Js.Json.t => string
let testnet: Js.Json.t => string

See the Encode.re file for more details.

Decode API

Decodes and validates a Tezos URI and returns the resulting JSON payment request. Raises an exception when the request is invalid, or when the URI does not match the expected network.

let mainnet: string => Js.Json.t
let testnet: string => Js.Json.t

See the Decode.re file for more details.

ReasonML Examples

Encode

let operation = {|
  [
    {
      "content": {
        "kind": "transaction",
        "amount": "399000",
        "destination": "KT1MFdSrM6LqGXaXAWuuXX4tWe8H3n5Xekyg"
      }
    },
    {
      "content": {
        "kind": "transaction",
        "amount": "129000",
        "destination": "KT1MFdSrM6LqGXaXAWuuXX4tWe8H3n5Xekyg"
      }
    }
  ]
|}

let encodedLink = TezosUri.Encode.testnet(Js.Json.parseExn(operation))

Decode

let decodedObject = TezosUri.Decode.testnet(encodedLink)

Contribute

How to build

Get the code and the dependencies:

git clone https://gitlab.com/smartcontractlabs/tezos-uri.git
cd tezos-uri
npm install

Then, to build once, run:

npm run build

To compile when changes are made, run:

npm run start

To make a production ready bundle, run:

npm run make:build

Testing

The codebase is covered by tests, using the @glennsl/bs-jest bindings for the Jest testing framework. The tests are run with JavaScript files generated by the BuckleScript compiler (not the ReasonML source files).

You can run these tests with npm:

npm run test

Generating Docs

First, set up the documentation generator and generate stylesheets:

npm run bsdoc:init

Then build the HTML:

npm run bsdoc:build

License

MIT

Credits

This project is built by Smart Contract Labs and funded by TQ Tezos.