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

@hyperledgendary/runhfsc

v0.0.2

Published

Simple CLI for testing transactions

Downloads

3

Readme

runhfsc - Development REPL for Fabric/IBP

A simple CLI for testing smart contracts from the command line. Quick and simple general purpose application.

Usable with Hyperledger Fabric version2 or IBM Blockchain Platform

asciicast

Installation

It's a nodejs v12 application, so install that first.

npm install -g @hyperledgendary/runhfsc

Usage

You need to have available the 'Gateway' JSON or YAML connection profile, and have an 'Application' wallet with an identity to use.

Run runhfsc with options to specify these. If you give relative paths, then they are assumed to tbe related to ~/.ibpwallets for the wallet, and ~/.ibpgateways for the gateway

runhfsc --wallet org1 --gateway org1/Gateway.json
[default] <user>@<channel>:<contractid> - $ 

The command prompt you are presented with tells you the user you are currently connected with, and the channel and the contract that you are targetting.

(aside the default indicates a label marking the combination of wallet and gateway - not fully implemented yet)

To be able to 'evaluate' or 'submit' a transaction, you need to specify a user, channel and contract.

[default] <user>@<channel>:<contractid> - $ user appid
User set to appid
Connected to Fabric 

Then the channel

[default] appid@<channel>:<contractid> - $ channel mychannel
Channel set to mychannel

Then the contract

[default] appid@mychannel:<contractid> - $ contract fabcar
Contract set to fabcar

Now to run a transaction

Run transactions

Transactions can either by 'evaluated' - a query type operation only sent to one peer - or 'submited' - where the transaction is sent to all required peers for execution and endorsement.

Two commands evaluate and submit are available, with the same syntax

[default] appid@mychannel:fabcar - $ evaluate queryAllCars '[]'
Submitted args []
> [{"Key":"CAR0","Record":{"color":"blue","docType":"car","make":"Toyota","model":"Prius","owner":"Tomoko"}},{"Key":"CAR1","Record":{"color":"red","docType":"car","make":"Ford","model":"Mustang","owner":"Brad"}},{"Key":"CAR2","Record":{"color":"green","docType":"car","make":"Hyundai","model":"Tucson","owner":"Jin Soo"}},{"Key":"CAR3","Record":{"color":"yellow","docType":"car","make":"Volkswagen","model":"Passat","owner":"Max"}},{"Key":"CAR4","Record":{"color":"black","docType":"car","make":"Tesla","model":"S","owner":"Adriana"}},{"Key":"CAR5","Record":{"color":"purple","docType":"car","make":"Peugeot","model":"205","owner":"Michel"}},{"Key":"CAR6","Record":{"color":"white","docType":"car","make":"Chery","model":"S22L","owner":"Aarav"}},{"Key":"CAR7","Record":{"color":"violet","docType":"car","make":"Fiat","model":"Punto","owner":"Pari"}},{"Key":"CAR8","Record":{"color":"indigo","docType":"car","make":"Tata","model":"Nano","owner":"Valeria"}},{"Key":"CAR9","Record":{"color":"brown","docType":"car","make":"Holden","model":"Barina","owner":"Shotaro"}}]

Note the parameters to the function MUST be a JSON format string - in this case this is empty. To give arguments, for example...

[default] appid@mychannel:fabcar # $ evaluate queryCar '["CAR1"]'
Submitted args ["CAR1"]
> {"color":"red","docType":"car","make":"Ford","model":"Mustang","owner":"Brad"}

Add the @json option to get the output formatted

default] appid@mychannel:fabcar # $ evaluate @json queryCar '["CAR1"]'
Submitted args ["CAR1"]
> {
  color: 'red',
  docType: 'car',
  make: 'Ford',
  model: 'Mustang',
  owner: 'Brad'
}

To submit a transaction, eg to update an owner

[default] appid@mychannel:fabcar - $ evaluate queryCar '["CAR9"]'
Submitted queryCar  CAR9
> {"color":"brown","docType":"car","make":"Holden","model":"Barina","owner":"fred"}
[default] appid@mychannel:fabcar # $ submit changeCarOwner '["CAR9","BILL"]'
Submitted changeCarOwner  CAR9,BILL
> 
[default] appid@mychannel:fabcar # $ evaluate queryCar '["CAR9"]'
Submitted queryCar  CAR9
> {"color":"brown","docType":"car","make":"Holden","model":"Barina","owner":"BILL"}

metadata

There is a shortcut to get hold of metadata of the contract. This lets you see for example what transactions can be run.

[default] appid@mychannel:fabcar # $ metadata
> {
  '$schema': 'https://fabric-shim.github.io/release-1.4/contract-schema.json',
  contracts: {
    FabCar: {
      name: 'FabCar',
      contractInstance: { name: 'FabCar', default: true },
      transactions: [
        { name: 'initLedger', tags: [ 'submitTx' ] },
        { name: 'queryCar', tags: [ 'submitTx' ] },
        { name: 'createCar', tags: [ 'submitTx' ] },
        { name: 'queryAllCars', tags: [ 'submitTx' ] },
        { name: 'changeCarOwner', tags: [ 'submitTx' ] }
      ],
      info: { title: '', version: '' }
    },
    'org.hyperledger.fabric': {
      name: 'org.hyperledger.fabric',
      contractInstance: { name: 'org.hyperledger.fabric' },
      transactions: [ { name: 'GetMetadata' } ],
      info: { title: '', version: '' }
    }
  },
  info: { version: '1.0.0', title: 'fabcar' },
  components: { schemas: {} }
}