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

@rsksmart/ethr-did-utils

v1.1.0

Published

Utils for Ethr DID method in RSK network

Downloads

6

Readme

npm i ganache-core @rsksmart/ethr-did-utils

Features

Usage

You can start a Ganache server and deploy the registry from a new terminal or from Node.js

From a new terminal

Open a new terminal browse to the repo dir or clone it and run

npm run start-ganache-and-deploy

The output should be

Ganache started on port 8545 - rpcUrl: http://localhost:8545
Ethr DID Registry depoyed - registryAddress: 0xe87c1cd63e5eed53db7d4e839adb7a4646ecbf8d
netowrks: [ { name: 'ganache', rpcUrl: http://localhost:8545, registryAddress: 0xe87c1cd63e5eed53db7d4e839adb7a4646ecbf8d }]
mnemonic: cover lift maple eagle common differ trash stomach scene security section dismiss

Useful for demos

From Node.js

To start the server and deploy from Node.js

const { startGanacheServerAndDeployEthrDidRegistry } = require('@rsksmart/ethr-did-utils')

const port = process.env.PORT || 8545

startGanacheServerAndDeployEthrDidRegistry(port).then(({ blockchain, server, rpcUrl, eth, registryAddress, registry }) => {
  console.log(`Ganache started on port ${port} - rpcUrl: ${rpcUrl}`)
  console.log(`Ethr DID Registry depoyed - registryAddress: ${registryAddress}`)
  console.log(`netowrks: [ { name: 'ganache', rpcUrl: ${rpcUrl}, registryAddress: ${registryAddress} }]`)
  console.log(`mnemonic: ${blockchain.mnemonic}`)

  eth.accounts() // use ethjs
    .then(([me]) => registry.identityOwner(me)) // use ethr did registry contract
    .then(result => result[0])
    .then(owner => console.log(`My identity owner is ${owner}`))
    .then(() => server.close()) // use server.close to exit ganache
})

This sample script is in demo.js and can be run with node demo.js

The output should be

Ganache started on port 8545 - rpcUrl: http://localhost:8545
Ethr DID Registry depoyed - registryAddress: 0x351e99cafac04bd08333b06f1f8257ec5abfe242
netowrks: [ { name: 'ganache', rpcUrl: http://localhost:8545, registryAddress: 0x351e99cafac04bd08333b06f1f8257ec5abfe242 }]
mnemonic: host spin zero toddler chat tortoise project buffalo example ship chair human
My identity owner is 0xf9bcb26dbd250b22162ee513e9c6f9f373ced425

Useful for testing

API

async function startGanacheServerAndDeployEthrDidRegistry(port)

Start a Ganache server and deploy Ethr DID Registry

Parameters:

  • port port to for the server to listen on - default 8545

Returns: Promise<Object> with keys of startGanacheServer and deployEthrDidRegistry,

  • server
  • blockchain
  • eth
  • rpcUrl
  • registry
  • registryAddress
async function startGanacheServer(port)

Parameters:

  • port port to for the server to listen on - default 8545

Returns: Promise<Object> with keys

  • server the Ganache server started. It has a function close to close the server connection
  • blockchain the success result of the server listen callback
  • eth an ethjs instance using via HTTP the started server
  • rpcUrl the URL to use to connect to the node via RPC
async function deployEthrDidRegistry(eth)

Start a Ganache server and deploy Ethr DID Registry

It works only with auto-miner set on

Parameters:

  • eth an ethjs instance using via HTTP the started server

Returns:

  • registry an ethjs-contract instance of the deployed registry
  • registryAddress the address of the deployed Ethr DID Registry