Search code examples
node.jshyperledger-fabrichyperledgerhyperledger-composer

Connect to card while transaction in hyperldeger


I have run the network using the below command

composer-rest-server -c admin@mynetwork -n never -w true

In the network there are some other participants also like

Participant1 has p1@mynetwork card

Participant2 has p2@mynetwork card

Now the problem is how to connect to another card while doing the transaction.

I want to do the transaction1 with p1 card and transaction2 with p2 card.

How to do that connection while doing the transaction. I am using to call the transaction in nodejs by calling http://localhost:3000/api/transaction1


Solution

  • You can do it in 2 ways:

    1st way:

    You can create an account in github OAuth to authenticate user for your hyperledger rest server. What this does is that your rest-server will then get a wallet where user will upload their card and then activate that card. Now whatever transaction that you will perform will carry on being the participant, whose card that is.

    Steps:

    1. Export variable COMPOSOSER_PROVIDERS with your github clientID and clientSecret on your terminal.

    export COMPOSER_PROVIDERS='{"github":"provider":"github","module":"passportgithub","clientID":"c1e68c173a1*******","clientSecret":"**************a2219abc380fa43ace7519","authPath":"/auth/github","callbackURL":"/auth/github/callback","successRedirect":" ","failureRedirect":"/"}}'

    1. Install passport-github

    npm install -g passport-github

    1. start composer-rest-server with multiple user mode enabled

    composer-rest-server --card admin@mynetwork -n never -p 3000 -a true -m true

    1. Finally authenticate your github account at url

    localhost:3000/auth/github

    2nd way: (Not Preferable But Easiest :) )

    You can create composer rest server at different port using command

    composer-rest-server -c p1@mynetwork -n never -w true -p 4000
    

    Now whatever transaction you want to perform by participant1. Perform on port 4000.