1

I have a local Node.js app all ready to go that talks to the Fabric blockchain on my cloud Kubernetes cluster.

As I understand, this works because:

  1. I have a card
  2. in terminal composer import card
  3. in Node.js this.bizNetworkConnection.connect(NAME_OF_LOCALLY_IMPORTED_CARD)

So I'm confused how I would host this app on the cloud for the public where anyone can check it out. It sounds like I would have to do the following steps within the cloud machine before it can connect to my business network:

  1. Download the card
  2. Install Composer
  3. Import the card

I feel like there has to be an easier way to do this. What am I missing? If not, it seems like I can only host this app through a VPS solution where I can install whatever I want add files to the local filesystem.

atkayla
  • 8,143
  • 17
  • 72
  • 132

2 Answers2

1

In a production scenario, your application would likely manage the cards and store them for the users, and manage a mapping between your users and their cards. This is because in most scenarios your application will not just be accessing resources on the Fabric, but additional data sources and integration points too, so there is a wider need for the application to identify the user.

As you rightly say you would not expect users to Install Composer and manage their own card.

R Thatcher
  • 5,550
  • 1
  • 7
  • 15
  • But store the cards where? It seems like cards can only be stored on the local file system, where I usually don't have access to this on the cloud unless I'm using DigitalOcean or something. – atkayla Jan 30 '18 at 15:33
  • At the moment you will require to the local file system. In the future there is an open issue being worked on for storing the wallet (cards) on the cloud: https://github.com/hyperledger/composer/issues/3217 – R Thatcher Feb 01 '18 at 15:22
1

If your node JS app (for your public demo) is already able to interact (having imported and connected via API), then it will have imported it successfully to the cardstore wallet on that node. So you can just let 'joe public' access the Node js app at whatever public URL its available on, and 'it' interacts with the Fabric (your users interact with the NodeJS app). Your users don't have to download any cards in this scenario.

So the NodeJS app can use that one business network card (as its a demo) to interact with the business network you've deployed to your Fabric in K8's.

If you want to see different traceable history for each login, for demo purposes, then obviously you'll have to issue different identities in Composer for that business network (and map to a participant).

Paul O'Mahony
  • 6,740
  • 1
  • 10
  • 15
  • To clarify, I have Fabric in K8s after doing https://ibm-blockchain.github.io/setup/, and I did `composer card import` locally. My card can be seen at my local `~/.composer/cards` and `composer card list`. My Node.js app running locally e.g. `http://localhost:3000` can connect to that business network. Are you saying that when I put this Node.js app on the cloud e.g. Cloud Foundry, where it doesn't have access to the local file system `~/.composer/cards` anymore, it will still be able to find the card and connect? – atkayla Jan 30 '18 at 15:40
  • I'm saying that you will need to either export the card you have to disk, then transport it to the cloud. Then (assuming composer-cli is installed on the cloud instance) you can import it using `composer card import` into the cloud stored wallet. The nodeJS app running in the cloud can then access the card (with credentials) 'locally' - one would assume the IP information in the connection profile is still the same (in the card) to be able to access the runtime Fabric infrastructure. Make sense?. – Paul O'Mahony Jan 30 '18 at 16:19
  • Yes, that makes perfect sense, and exactly what I was thinking. "transport it to the cloud. Then (assuming composer-cli is installed on the cloud instance) you can import it using composer card import into the cloud stored wallet." So I need a service that will allow me to install composer-cli on the cloud and access the file system: DigitalOcean Droplet, Linode, IBM Virtual Server, stuff like that where I can ssh in and use a shell? Even if I just want to do a public demo available to everybody, sounds like I have to pay at least $5 a month? – atkayla Jan 30 '18 at 16:26
  • What do you mean by "you can install Composer CLI as a node app"? Are you saying in Node.js app's `package.json` I `npm install composer-cli` (locally, not globally). Then also as part of `package.json` do a script `post-install: ./node_modules/.../composer-cli card import`? – atkayla Jan 30 '18 at 17:58
  • I just tried the above and it does the same thing. It looks in `~/.composer/cards`. So this basically can't be hosted without a VPS? No problem if that's the case - just wanted to make sure. I found this: https://github.com/hyperledger/composer/issues/3121 "When running code that requires a business network card in a cloud environment, then using a local filesystem is impractical or impossible." – atkayla Jan 31 '18 at 01:01
  • I mean 'npm install' it as a node package. I don't know your Cloud env. You can choose to put the actions in your package.json. But installing the CLI local to your App is what I meant. This allows you to do the import. Your Node app would be able to look 'local' to its local filesystem, even though it serves public content. I am aware of issue 3121 that statement reflects production type issues where there's a need for cloud storage - in your case, you're setting up a demo. From what you've written, its feasible to have the wallet 'local' to your App - but only you will know that. – Paul O'Mahony Jan 31 '18 at 10:52
  • Even though it's a demo, I still need anyone to be able to go to myblockchainapp.com, so it's not a local demo, but a demo on the cloud. If I just hosted a Node.js app is on Cloud Foundry or something, it has no way to access the local file system, so the card cannot be imported and found, and it would not be able to connect to the business network. Because of that, I had to pay for a VPS, but I was able to get it all working. Until cards can found on cloud storage instead of having to be imported in the local file system, I don't think I can host an app for free. Thank you for your trouble. – atkayla Jan 31 '18 at 12:26
  • great news! Sure -, I only ever meant: local to the app (nothing else)? as the current means. And you're right, cloud storage needs addressing for sure. - best wishes. – Paul O'Mahony Jan 31 '18 at 14:50