Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rsksmart/ethr-did-utils

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rsksmart/ethr-did-utils

Utils for Ethr DID method in RSK network

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

logo

@rsksmart/ethr-did-utils

Utils for Ethr DID method in RSK network.

npm

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

FAQs

Package last updated on 29 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc