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

fabric-network-simple

v1.1.0

Published

A simplified wrapper for fabric-network

Downloads

18

Readme

fabric-network-simple

A simplified wrapper for fabric-network. Typescript usage is recommended for auto config checks.

Installation

npm install fabric-network-simple
yarn add fabric-network-simple

##Include

import fabricNetworkSimple from "fabric-network-simple";

Configuration

fabric-network-simple reads configurations from a config object as an argument in function initGateway

const config: fabricNetworkSimple.config = {
  channelName: "test-channel",
  contractName: "test-contract",
  connectionProfile: {
    name: "Network",
    version: "1.1",
    channels: {
      "test-channel": {
        orderers: ["orderer.example.com"],
        peers: ["peer0.org1.example.com", "peer0.org2.example.com"],
      },
    },
    organizations: {
      Org1: {
        mspid: "Org1MSP",
        peers: ["peer0.org1.example.com"],
        certificateAuthorities: ["ca-org1"],
      },
      Org2: {
        mspid: "Org2MSP",
        peers: ["peer0.org2.example.com"],
        certificateAuthorities: ["ca-org2"],
      },
    },
    orderers: {
      "orderer.example.com": {
        url: "grpcs://localhost:7050",
        grpcOptions: {
          "ssl-target-name-override": "orderer.example.com",
        },
        tlsCACerts: {
          path:
            "test/ordererOrganizations/example.com/orderers/orderer.example.com/tlscacerts/example.com-cert.pem",
        },
      },
    },
    peers: {
      "peer0.org1.example.com": {
        url: "grpcs://localhost:7051",
        grpcOptions: {
          "ssl-target-name-override": "peer0.org1.example.com",
        },
        tlsCACerts: {
          path:
            "test/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tlscacerts/org1.example.com-cert.pem",
        },
      },
      "peer0.org2.example.com": {
        url: "grpcs://localhost:8051",
        grpcOptions: {
          "ssl-target-name-override": "peer0.org2.example.com",
        },
        tlsCACerts: {
          path:
            "test/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tlscacerts/org2.example.com-cert.pem",
        },
      },
    },
  },
  identity: {
    mspid: 'Org1MSP',
    certificate: '-----BEGIN CERTIFICATE-----\nMIIB9DCCAZugAwIBAgIQX6iGazkZVMAKUvWR+bX//DAKBggqhkjOPQQDAjBbMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzENMAsGA1UEChMEb3JnMTEQMA4GA1UEAxMHY2Eub3JnMTAeFw0yMDA4\nMTQwNzI0MDBaFw0zMDA4MTIwNzI0MDBaME8xCzAJBgNVBAYTAlVTMRMwEQYDVQQI\nEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMRMwEQYDVQQDDApB\nZG1pbkBvcmcxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEywRWLrKHCeMACzKq\noaktPkjczbxAA+zqS5AVlKQUVwAmiUaNF/cQHnjdHeDNNYZAAaUwRY8xnxP4DJRT\n7g5GT6NNMEswDgYDVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0jBCQw\nIoAg2ZieZeymeQE20xuqymU3R0kMoRUnUO+ic3TqcVW0ZWEwCgYIKoZIzj0EAwID\nRwAwRAIgbBhgPWUo8pnOZhODSjsKqzaP8jxLv3G+3hG/v32b7OICIELn9dQ3ua0Y\nOf6Q2XKcXvI/6BFXEMJzJkCv52MKTjKl\n-----END CERTIFICATE-----\n',
    privateKey: '-----BEGIN PRIVATE KEY-----\r\nMIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgpiKVKhRCAhxWB5of\r\n64AOB7741SQPNARB2Ob12Ag7TDOhRANCAATLBFYusocJ4wALMqqhqS0+SNzNvEAD\r\n7OpLkBWUpBRXACaJRo0X9xAeeN0d4M01hkABpTBFjzGfE/gMlFPuDkZP\r\n-----END PRIVATE KEY-----\r\n',
  },
  settings: {
    enableDiscovery: true,
    asLocalhost: true,
  }

Usage

Say we have a query function "set", and invoke function "get" that gets/sets a number to a variable on the chaincode

//constructor
const fabricNetwork = 
  new fabricNetworkSimple(
    config //config object, see example config section
  );

//sets variable to 5
const invokeResult = 
  await fabricNetwork.invokeChaincode(
    'set', //chaincode method
    [5], //arguments
    {} //transient data
  );
//gets variable from ledger
const queryResult = 
  await fabricNetwork.queryChaincode(
    'get', //chaincode method
    [] //arguments
  );
console.log('queryResult'); //prints 5