Giter Site home page Giter Site logo

ibm / fabcar-blockchain-sample Goto Github PK

View Code? Open in Web Editor NEW
107.0 13.0 85.0 739.66 MB

Use a Kubernetes cluster to deploy a Fabric network smart contract onto blockchain

Home Page: https://developer.ibm.com/patterns/write-a-smart-contract-for-the-fabcarcommercial-paper-or-iks-cluster-with-saas-v2-beta-network-think/

License: Apache License 2.0

JavaScript 41.41% HTML 3.99% TypeScript 30.48% CSS 24.13%
kubernetes blockchain hyperledger fabric containers

fabcar-blockchain-sample's People

Contributors

dependabot[bot] avatar horeaporutiu avatar ljbennett62 avatar raheelzubairy avatar riehab avatar sandhya-nayak avatar taijihagino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fabcar-blockchain-sample's Issues

How to consume 1 localhost log

Sorry for the inconvenience, I wanted to ask how I can bring 1 record only in the path localhost: 8081 / queryCalls that is, to be able to show in json the first record only

On the server in app.js is this GET route but I do not get an idea in chrome or postman how to consume only the first record
app.get ('/ queryAllCars', (req, res) => {
  network.queryAllCars ()
    .then ((response) => {
        var carsRecord = JSON.parse (response);
        res.send (carsRecord)
      });
})

Failed to enroll admin user "admin": Error: Calling enrollment endpoint failed with error [Error: write EPROTO 4589469120:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:33

Today the blockchain extension got automatically updated and the docker images and everything was updated to the lastest hyperledger fabric and after the update the enrollAdmin no longer works. I keep getting this error

Failed to enroll admin user "admin": Error: Calling enrollment endpoint failed with error [Error: write EPROTO 4589469120:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:33

Enroll admin.js


/*
 * SPDX-License-Identifier: Apache-2.0
 */

'use strict';

const FabricCAServices = require('fabric-ca-client');
const { Wallets } = require('fabric-network');
const fs = require('fs');
const path = require('path');

const ccpPath = path.join(process.cwd(), 'config.json');
const ccpJSON = fs.readFileSync(ccpPath, 'utf8');
const ccp = JSON.parse(ccpJSON);

async function main() {
    try {

        // Create a new CA client for interacting with the CA.
        const caInfo = ccp.certificateAuthorities['Org1CA'];
        const caTLSCACerts = caInfo.tlsCACerts.pem;
        const ca = new FabricCAServices(caInfo.url, { trustedRoots: caTLSCACerts, verify: false }, caInfo.caName);

        // Create a new file system based wallet for managing identities.
        const walletPath = path.join(process.cwd(), 'wallet');
        const wallet = await Wallets.newFileSystemWallet(walletPath);
        console.log(`Wallet path: ${walletPath}`);

        // Check to see if we've already enrolled the admin user.
        const identity = await wallet.get('admin');
        if (identity) {
            console.log('An identity for the admin user "admin" already exists in the wallet');
            return;
        }

        // Enroll the admin user, and import the new identity into the wallet.
        const enrollment = await ca.enroll({ enrollmentID: 'admin', enrollmentSecret: 'adminpw' });
        const x509Identity = {
            credentials: {
                certificate: enrollment.certificate,
                privateKey: enrollment.key.toBytes(),
            },
            mspId: 'Org1MSP',
            type: 'X.509',
        };
        await wallet.put('admin', x509Identity);
        console.log('Successfully enrolled admin user "admin" and imported it into the wallet');

    } catch (error) {
        console.error(`Failed to enroll admin user "admin": ${error}`);
        process.exit(1);
    }
}

main();

Fabric Connection

{
    "certificateAuthorities": {
        "Org1CA": {
            "caName": "ca",
            "url": "http://localhost:17050"
        }
    },
    "client": {
        "connection": {
            "timeout": {
                "orderer": "300",
                "peer": {
                    "endorser": "300"
                }
            }
        },
        "organization": "Org1MSP"
    },
    "name": "Org1",
    "organizations": {
        "Org1MSP": {
            "certificateAuthorities": [
                "Org1CA"
            ],
            "mspid": "Org1MSP",
            "peers": [
                "Org1Peer1"
            ]
        }
    },
    "peers": {
        "Org1Peer1": {
            "url": "grpc://localhost:17051"
        }
    },
    "version": "1.0.0"
}

Config.json

{
    "name": "local_fabric",
    "version": "1.0.0",
    "client": {
        "organization": "Org1",
        "connection": {
            "timeout": {
                "peer": {
                    "endorser": "300"
                }
            }
        }
    },
    "organizations": {
        "Org1": {
            "mspid": "Org1MSP",
            "peers": [
                "Org1Peer1"
            ],
            "certificateAuthorities": [
                "Org1CA"
            ]
        }
    },
    "peers": {
        "Org1Peer1": {
            "url": "grpcs://localhost:17051",
            "tlsCACerts": {
                "pem": "-----BEGIN CERTIFICATE-----\nMIICWDCCAf2gAwIBAgIQa3dF7ohCzTcdncLO//g5ZDAKBggqhkjOPQQDAjB2MQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEfMB0GA1UEAxMWdGxz\nY2Eub3JnMS5leGFtcGxlLmNvbTAeFw0yMDAyMTUwODI0MDBaFw0zMDAyMTIwODI0\nMDBaMHYxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQH\nEw1TYW4gRnJhbmNpc2NvMRkwFwYDVQQKExBvcmcxLmV4YW1wbGUuY29tMR8wHQYD\nVQQDExZ0bHNjYS5vcmcxLmV4YW1wbGUuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0D\nAQcDQgAEN1eAvtDLqgISELt27t69CB9JbZowd3VsjGDMrycInT0ojWJBnZtR3HMb\ncRzvC9QZYJv4hvYzkh38RElUCLBFd6NtMGswDgYDVR0PAQH/BAQDAgGmMB0GA1Ud\nJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDATAPBgNVHRMBAf8EBTADAQH/MCkGA1Ud\nDgQiBCBMSLNDdXJPq9BhTzyTM4oEVoJFcdBCXLVhh7z6CKEoMDAKBggqhkjOPQQD\nAgNJADBGAiEAnboUbojFiG6iDCLfuuYXtnHB1zRFNU5LH5fgDEElyV8CIQCU9tn3\n1OGDCWQNyiY7FbOSY0lBPtG6Ou5oKYmdafDAFQ==\n-----END CERTIFICATE-----\n"
            },
            "grpcOptions": {
                "ssl-target-name-override": "peer0.org1.example.com",
                "hostnameOverride": "peer0.org1.example.com"
            }
        }
    },
    "certificateAuthorities": {
        "Org1CA": {
            "url": "https://localhost:17050",
            "caName": "ca",
            "tlsCACerts": {
                "pem": "-----BEGIN CERTIFICATE-----\nMIICUTCCAfegAwIBAgIQNmwOWto6X31knKCsv4m+dTAKBggqhkjOPQQDAjBzMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu\nb3JnMS5leGFtcGxlLmNvbTAeFw0yMDAyMTUwODI0MDBaFw0zMDAyMTIwODI0MDBa\nMHMxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T\nYW4gRnJhbmNpc2NvMRkwFwYDVQQKExBvcmcxLmV4YW1wbGUuY29tMRwwGgYDVQQD\nExNjYS5vcmcxLmV4YW1wbGUuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE\n2MkQuefT18WfWyyPlPrzcwjKBMFhdXvyK6NjA6w1JQ7O3W+qgC64Auu7jf2CxtFX\nGMaGswEdUOB1dHymha8meaNtMGswDgYDVR0PAQH/BAQDAgGmMB0GA1UdJQQWMBQG\nCCsGAQUFBwMCBggrBgEFBQcDATAPBgNVHRMBAf8EBTADAQH/MCkGA1UdDgQiBCDt\nE0NX3M/rohsg624tZnKZQWSBHk0IJY7hW9FlVwNyOzAKBggqhkjOPQQDAgNIADBF\nAiASloNq0eftTRWrJ1i/xv5oKN42pOecDlOPVDH8dAcM1wIhAO52J6OIYYET9jv7\niuTu4z2T4CtF/dkOo7Njar3BnHgj\n-----END CERTIFICATE-----\n"
            },
            "httpOptions": {
                "verify": false
            }
        }
    }
}

This stackoverflow https://stackoverflow.com/questions/54137174/hyperledger-fabric-calling-enrollment-endpoint-failed-with-error answers the issue but the yaml file is not available in the server or the client folder, which file should be updated to fix this issue?

New extension panel after update
image

gatewayDiscovery

I'm the IBM Blockchain Platform SRE. I tried this sample to interact with IPB v2. I works find and the document of this sample is very detailed.

However, when our customers of IBP try this sample, some of them encounter the "discovery error:access denied" error. After our investigation, it's because they didn't set the gatewayDiscovery properly base on your document.

Instead of 'fabric-client' API, the fabcar sample utilizes the high level 'fabric-network' to interact with smart contracts, which is a new feature in fabric-node-sdk 1.4. Some of the customer were not aware of that. So they choose to ignore it.

My proposal is, could you please document a little bit more about gatewayDiscovery or highlight gatewayDiscovery is required. So the users will not ignore it.

Many thanks.

Revoke User

Should be good to have access to delete users. as well.

node enrollAdmin.js: error: [FabricCAClientService.js]: Failed to enroll app-admin

Dear Experts,

I am at step 4 run the Application, and while performing node enrollAdmin.js, i am facing the following error:
node enrollAdmin.js
2019-08-16T20:45:07.623Z - error: [FabricCAClientService.js]: Failed to enroll app-admin, error:%o message=Calling enrollment endpoint failed with error [Error: connect ETIMEDOUT 184.173.1.18:31317], stack=Error: Calling enrollment endpoint failed with error [Error: connect ETIMEDOUT 184.173.1.18:31317]
at ClientRequest.request.on (/home/assure/IBM-fabcar/fabcar-blockchain-sample/web-app/server/node_modules/fabric-ca-client/lib/FabricCAClient.js:487:12)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:401:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:66:8)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickCallback (internal/process/next_tick.js:181:9)
Failed to enroll admin user app-admin: ${error}

while checking the reachability towards 184.173.1.18, seems it is not reachable and port 31317 is not open on that CA server.
Can you please advise why this server is not reachable?
Any other alternatives to that server?

Thank you

Failed to enrol Admin. Error - code: 20, message: 'Authentication failure'

I change admin credentials from app-admin/app-adminpw to org1-admin/org1-adminpw .So I getting the below error

error: [FabricCAClientService.js]: Failed to enroll org1-admin, error:%o message=fabric-ca request enroll failed with errors [[ { code: 20, message: 'Authentication failure' } ]], stack=Error: fabric-ca request enroll failed with errors [[ { code: 20, message: 'Authentication failure' } ]]

Team, please help me with this.Its urgent

error: [Network]: _initializeInternalChannel: no suitable peers available to initialize from

Running this app inside a local environment and trying to create a car using the angular front end is throwing this error.
error: [Network]: _initializeInternalChannel: no suitable peers available to initialize from Failed to evaluate transaction: Error: no suitable peers available to initialize from { error: 'no suitable peers available to initialize from' }

I am using the connection.json from the location contract/local_fabric/connection.json and the config.json is configured to allow gatewayDiscovery and is set to "gatewayDiscovery": { "enabled": true, "asLocalhost": true }

Any help will be well appreciated.

Step 2: Choose IBM Blockchain Platform: Package a Smart Contract Project continues to throw error message

When completing Step 2 of the tutorial ("Package the Smart Contract") and after navigating to the Contract folder as the root, when one attempts to select the "IBM Blockchain Platform: Package a Smart Contract Package", and error is thrown that reads:

"Failed to determine workspace language type, supported languages are JavaScript, TypeScript, Go and Java. Please ensure your contract's root-level directory is open in the Explorer."

@ljbennett62

Failed to register user user1: Error: fabric-ca request register failed with error.

node registerUser.js
Wallet path: C:\Users\07\OneDrive\Desktop\Final Try\fabcar-blockchain-sample\web-app\server\wallet
Failed to register user user1: Error: fabric-ca request register failed with errors [[{"code":0,"message":"Registration of 'user1' failed in affiliation validation: Failed getting affiliation 'org1.department1': : scode: 404, code: 63, msg: Failed to get Affiliation: sql: no rows in result set"}]]

Failed to register user user1.Failed to get Affiliation.
Here, in this I'm geting error as failed to Register user user1.msg: Failed to get Affiliation: sql: no rows in result set".

Can not run createCar function

Hello. I found a bug web-app/server/app.js line27
We can not run createCar because of this bug.
Incorrect:var carsRecord = JSON.parse(JSON.parse(response));
correct:var carsRecord = JSON.parse(response);

Please modify this code.
Thank you.

Client GUI is Based on Angular now, not Vue

The README says the web client is based on Vue JS framework but as of 16 days ago(?) it seems the basis for the client was switched to Angular. The documentation needs adjustment. The client is on port 4200 as a result and the start up requires entering npm start, not npm run serve

error in Start the application server

I managed to run all the steps 1-6 with success
on Step 7 ran Enroll admin and Register User steps both with success but when I ran "npm start "
I got an error .... (I am running Windows 7 )
image

function that does not exist: initLedger

Under ⇧⌘P I could not find IBM Blockchain Platform: Package a Smart Contract Project, so I used  IBM Blockchain Platform: Export Package.
Instead of the [email protected] I saw [email protected], which I used.
Later, when I instantiated the smart contract I got the error message: 
Error instantiating smart contract: transaction returned with failure: Error: You've asked to invoke a function that does not exist: initLedger

Getting - Error: socket hang up when execute "node registerUser.js"

Getting below error when execute "node registerUser.js" . I tried with node version 12.20.0 , 14.15.4 but issue is same and not sure exact reason for the issue. Could you please assist me to troubleshoot the issue.

Failed to register user user1: Error: Calling register endpoint failed with error [Error: socket hang up
at connResetException (internal/errors.js:607:14)
at Socket.socketOnEnd (_http_client.js:493:23)
at Socket.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'ECONNRESET'
}]

Unable to create Certificate Authority

Hello admin. I trying build sample. when I'm done to step

Create your organization and your entry point to your blockchain
Create your peer organization CA

Click Add Certificate Authority.
Click IBM Cloud under Create Certificate Authority and Next.
Give it a Display name of Org1 CA.
Specify an Admin ID of admin and Admin Secret of adminpw.

I get error below

Unable to create Certificate Authority
{"message":"Operation error"}

Please help me fix. Thank you very much.

npm install for client shows vulnerabilities fixing them breaks client

Fresh clone of fabcar-blockchain-sample.
I run npm install:

jjsretina:client jjs$ npm install

> [email protected] install /Users/jjs/Documents/Villanova/ECE8498Spring2019/Week13/fabcar-blockchain-sample/web-app/client/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download 
[fsevents] Success: "/Users/jjs/Documents/Villanova/ECE8498Spring2019/Week13/fabcar-blockchain-sample/web-app/client/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote

> [email protected] install /Users/jjs/Documents/Villanova/ECE8498Spring2019/Week13/fabcar-blockchain-sample/web-app/client/node_modules/node-sass
> node scripts/install.js

Cached binary found at /Users/jjs/.npm/node-sass/4.11.0/darwin-x64-64_binding.node

> [email protected] postinstall /Users/jjs/Documents/Villanova/ECE8498Spring2019/Week13/fabcar-blockchain-sample/web-app/client/node_modules/node-sass
> node scripts/build.js

Binary found at /Users/jjs/Documents/Villanova/ECE8498Spring2019/Week13/fabcar-blockchain-sample/web-app/client/node_modules/node-sass/vendor/darwin-x64-64/binding.node
Testing binary
Binary is fine
added 1198 packages from 1330 contributors and audited 40441 packages in 12.027s
found 9 vulnerabilities (2 low, 7 high)
  run `npm audit fix` to fix them, or `npm audit` for details

If I do npm audit fix, the app will not open:

jjsretina:client jjs$ npm start

> [email protected] start /Users/jjs/Documents/Villanova/ECE8498Spring2019/Week13/fabcar-blockchain-sample/web-app/client
> ng serve

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
                                                                                          
Date: 2019-04-29T01:44:30.551Z
Hash: 84be1010ddee4fbede4c
Time: 5392ms
chunk {main} main.js, main.js.map (main) 140 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 237 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.4 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.46 MB [initial] [rendered]

ERROR in ./src/styles.css (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./src/styles.css)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
SyntaxError

(1:4) Unknown word

> 1 | // SCSS Color Palette Variables
    |    ^
  2 | $ibm-color__black-100: #000000;
  3 | $ibm-color__blue-10: #EDF4FF;

ℹ 「wdm」: Failed to compile.

Any ideas?

Getting error while executing registerUser.js(Need help in priority)

I am using the IBM Blockchain platform console to create the network and using the fabcar sample to connect to the network with SDK. The enrollAdmin.js script is successful but the registerUser.js is giving the below error message.

Failed to register user user1: TypeError [ERR_INVALID_ARG_TYPE]: The "options.ca" property must be one of type string, Buffer, TypedArray, or DataView. Received type object.

As per my analysis the issue is with the line.
const secret = await ca.register({ affiliation: '', enrollmentID: userName, role: 'client' }, adminIdentity);

I am not sure how to resolve it,could you please help on this.

Node.js v10.x is required to start the client

Followed the steps in README, but failed to start the client.

This is different from the README declaration that both Node v8.x and v10.x will work.

Logs

$ cd web-app/client
$ npm start

> [email protected] start /home/bafu/codes/fabcar-blockchain-sample/web-app/client
> ng serve

You are running version v8.17.0 of Node.js, which is not supported by Angular CLI 8.0+.
The official Node.js version that is supported is 10.9 or greater.

Please visit https://nodejs.org/en/ to find instructions on how to update Node.js.
npm ERR! code ELIFECYCLE
npm ERR! errno 3
npm ERR! [email protected] start: `ng serve`
npm ERR! Exit status 3
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/bafu/.npm/_logs/2020-03-23T13_37_30_531Z-debug.log

Environment

fabcar-blockchain-sample: commit 7d850c3

npm start command is giving issue

Hi Team,

We're getting the following error, while following the step 7, any idea how to resolve it.

[email protected] start C:\Sapna\ContainerCrush\Hyperledger\fabcar-blockchain-sample\web-app\server
./node_modules/nodemon/bin/nodemon.js src/app.js
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: ./node_modules/nodemon/bin/nodemon.js src/app.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:

unable to use the server/client application

everything sound correct, I created the network using IPB 2.0. when I start the server, i am getting "clien.JS: Channel not found for the name mychannel.
image
I checked the settings of my platform and 'mychannel' is there.
Do you have any Idea? do you more details?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.