GithubHelp home page GithubHelp logo

aws-samples / non-profit-blockchain Goto Github PK

View Code? Open in Web Editor NEW
373.0 31.0 285.0 13.56 MB

Builds a blockchain network and application to track donations to non-profit organizations, using Amazon Managed Blockchain

License: Apache License 2.0

Shell 17.81% JavaScript 29.09% TypeScript 15.79% HTML 7.95% Dockerfile 0.02% SCSS 29.34%

non-profit-blockchain's Introduction

[ARCHIVED] Amazon Managed Blockchain Workshop

This repository is now archived. For hands-on experience use one of our official workshops.

Updated to support Fabric v1.4x

Building and deploying an application for Hyperledger Fabric on Amazon Managed Blockchain

This workshop builds a Hyperledger Fabric blockchain network using Amazon Managed Blockchain. Once the Fabric network has been created, you will deploy a 3-tier application that uses the Fabric network to track donations to a non-profit organisation, and track how those donations are spent by the non-profit. Donations and spending are tracked on a Hyperledger Fabric blockchain network with both donors and non-profits (NGO's) being members of the network. The 3-tier application consists of the following components:

  • Node.js / Angular user interface application, accessing services provided by a RESTful API
  • RESTful API, running as a Node.js Express application, using the Hyperledger Fabric Client SDK to query and invoke chaincode
  • Fabric Chaincode, written in Node.js, deployed to a Hyperledger Fabric network

This workshop will build a Hyperledger Fabric blockchain network using Amazon Managed Blockchain, deploy the chaincode, start the RESTful API server and finally run a UI application that uses the RESTful API to interact with the Fabric network. The workshop is divided into four parts:

  1. Building a Hyperledger Fabric blockchain network using Amazon Managed Blockchain. Instructions can be found in the folder: ngo-fabric
  2. Deploying the chaincode, or smart contract, that provides the donation and spend tracking functionality. Instructions can be found in the folder: ngo-chaincode
  3. Starting the RESTful API server that exposes the chaincode functions to client applications. Instructions can be found in the folder: ngo-rest-api
  4. Running the User Interface application. Instructions can be found in the folder: ngo-ui

Getting started

To build the network, deploy the chaincode, start the RESTful API server and run the application, follow the README instructions in parts 1-4, in this order:

  • Part 1: Start the workshop by building the Hyperledger Fabric blockchain network using Amazon Managed Blockchain.
  • Part 2: Deploy the non-profit chaincode.
  • Part 3: Run the RESTful API server.
  • Part 4: Run the application.
  • Part 5: Add a new member to the network.
  • Part 6: Read and write to the blockchain with Amazon API Gateway and AWS Lambda.
  • Part 7: Use blockchain events to notify users of NGO donations.
  • Part 8: Deploy Hyperledger Explorer.
  • Part 9: Integrating blockchain users with Amazon Cognito.

Cleanup

To clean up your resources delete the Hyperledger Fabric network managed by Amazon Managed Blockchain and the AWS CloudFormation template as follows:

  • In the AWS CloudFormation console delete the stack with the stack name <your network>-fabric-client-node
  • In the Amazon Managed Blockchain console delete the member for your network. This will delete the peer node, the member, and finally, the Fabric network (assuming you created only one member)
  • In the AWS Cloud9 console delete your AWS Cloud9 instance

License

This library is licensed under the Apache 2.0 License.

non-profit-blockchain's People

Contributors

baizele avatar bertux avatar dependabot[bot] avatar ebaizel avatar elsenhuc avatar frbrkoala avatar hocanint-amzn avatar jpeddicord avatar maishsk avatar mcldg avatar rdg7739 avatar rprentyaws avatar vlasonfa 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

non-profit-blockchain's Issues

How to remove a chaincode on peer?

Hi, @MCLDG !

The amazon managed blockchain service and your repo resources are awesome!
I really appreciate what you have done!

During the chaincode development phase I have installed a lot chaincodes with different versions. I have managed to delete chaincode from the peer file system.

My question is - is there a way to kill the container that corresponds to the chaincode shim for each installed cc?

Thanks!

Can not update channel with the new configuration (includes 3 orgs in 1 channel)

I have completed all parts in your tutorials. Everything works fine.

After that, i try to add 3rd member follow steps in Part 5. But i got an error in Step 11: Account A updates the channel with the new configuration like below:

Error: got unexpected status: BAD_REQUEST -- error authorizing update: error validating DeltaSet: policy for [Group] /Channel/Application not satisfied: Failed to reach implicit threshold of 2 sub-policies, required 1 remaining

Screen Shot 2019-06-27 at 4 53 06 PM

This is my config in ~/configtx.yaml file

# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# 
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# or in the "license" file accompanying this file. This file is distributed 
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
# express or implied. See the License for the specific language governing 
# permissions and limitations under the License.

################################################################################
#
#   Section: Organizations
#
#   - This section defines the different organizational identities which will
#   be referenced later in the configuration.
#
################################################################################
Organizations:
    - &Org1
        Name: 

        # ID to load the MSP definition as
        ID: 

        MSPDir: /opt/home/admin-msp

        AnchorPeers:
            # AnchorPeers defines the location of peers which can be used
            # for cross org gossip communication.  Note, this value is only
            # encoded in the genesis block in the Application section context
            - Host:
              Port:
    - &Org2
        Name: 
        ID: 
        MSPDir: 
        AnchorPeers:
            - Host:
              Port:

    - &Org3
        Name: 
        ID: 
        MSPDir: 
        AnchorPeers:
            - Host:
              Port:

################################################################################
#
#   SECTION: Application
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for application related parameters
#
################################################################################
Application: &ApplicationDefaults

    # Organizations is the list of orgs which are defined as participants on
    # the application side of the network
    Organizations:

################################################################################
#
#   Profile
#
#   - Different configuration profiles may be encoded here to be specified
#   as parameters to the configtxgen tool
#
################################################################################
Profiles:
    OneOrgChannel:
        Consortium: AWSSystemConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
    TwoOrgChannel:
        Consortium: AWSSystemConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2
    ThreeOrgChannel:
        Consortium: AWSSystemConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2
                - *Org3

What should i do to fix this problem?

Error when running aws s3 cp

I get this when running: aws s3 cp s3://managedblockchain-beta/service-2.json .

fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden

Any ideas?

Error after managed blockchain update on April 8th

Hi,
I tried the code on new version of AWS managed blockchain, and this step is not working:

cd ~/non-profit-blockchain/ngo-fabric
source fabric-exports.sh

The line:

endpoint=$(aws managedblockchain get-node --region $REGION --network-id $NETWORKID --member-id $MEMBERID --node-id $nodeID --query 'Node.Endpoint' --output text)
peerEventPort=$(aws managedblockchain get-node --region $REGION --network-id $NETWORKID --member-id $MEMBERID --node-id $nodeID --query 'Node.FrameworkAttributes.Fabric.PeerEventPort' --output text)
eventEndPoint="${endpoint::-5}$peerEventPort"

Give None or empty response.

Thanks!

BAD_REQUEST -- Attempted to include a member which is not in the consortium

This is the first time I create a test network and I am having the following issue while creating a channel.

Apparently the docker script is not creating the /opt/home folder and therefore I I always get this error on Part 1 - Step 5:

cli peer channel create -c $CHANNEL -f /opt/home/$CHANNEL.pb -o $ORDERER --cafile $CAFILE --tls --timeout 900s

2019-07-16 20:21:55.001 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Error: got unexpected status: BAD_REQUEST -- Attempted to include a member which is not in the consortium

Does anyone have the same issue?

Thanks

Creating client node is imposible it repeat the same eror again and again

~/non-profit-blockchain/ngo-fabric (master) $ ./vpc-client-node.sh
Creating VPC - TODO. Create the VPC, subnets, security group, EC2 client node, VPC endpoint
Create a keypair
Searching for existing keypair named ngo-keypair
Keypair ngo-keypair already exists. Please choose another keypair name by editing this script.

Trying to run the user interface

Hi, i'm getting the following error after npm start:

Schema validation failed with the following errors:
Data path ".builders['app-shell']" should have required property 'class'.
Error: Schema validation failed with the following errors:
Data path ".builders['app-shell']" should have required property 'class'.
at MergeMapSubscriber._registry.compile.pipe.operators_1.concatMap.validatorResult [as project] (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/src/workspace/workspace.js:215:42)
at MergeMapSubscriber._tryNext (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:69:27)
at MergeMapSubscriber._next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:59:18)
at MergeMapSubscriber.Subscriber.next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:67:18)
at MergeMapSubscriber.notifyNext (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:92:26)
at InnerSubscriber._next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/InnerSubscriber.js:28:21)
at InnerSubscriber.Subscriber.next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:67:18)
at MapSubscriber._next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/map.js:55:26)
at MapSubscriber.Subscriber.next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:67:18)
at SwitchMapSubscriber.notifyNext (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/switchMap.js:86:26)
at InnerSubscriber._next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/InnerSubscriber.js:28:21)
at InnerSubscriber.Subscriber.next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:67:18)
at /home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/util/subscribeTo.js:17:28
at Object.subscribeToResult (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/util/subscribeToResult.js:10:45)
at SwitchMapSubscriber._innerSub (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/switchMap.js:65:54)
at SwitchMapSubscriber._next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/switchMap.js:55:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: ng serve --host 0.0.0.0 --port 8080 --disableHostCheck
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:
npm ERR! /home/ec2-user/.npm/_logs/2019-10-24T20_08_59_729Z-debug.log

i have tried another node version, and got the same error.

Part 4 - Problem starting Angular.js app

Everything was going great until the REST app where first in Part 3, the curl command failed with:
[2019-07-25T23:43:31.176] [ERROR] NGOAPI - ##### POST on Users - Failed to register the username michael for organization Org1 with::failed Error: Enrollment failed with errors [[{"code":20,"message":"Authorization failure"}]] [2019-07-25T23:43:34.274] [INFO] NGOAPI - ##### New request for URL /health [2019-07-25T23:43:39.674] [INFO] NGOAPI - ##### dummySpend GET on Donation - username : michael [2019-07-25T23:43:39.674] [INFO] NGOAPI - ##### dummySpend GET on Donation - userOrg : Org1 [2019-07-25T23:43:39.674] [INFO] NGOAPI - ##### dummySpend GET on Donation - channelName : mychannel [2019-07-25T23:43:39.674] [INFO] NGOAPI - ##### dummySpend GET on Donation - chaincodeName : ngo [2019-07-25T23:43:39.674] [INFO] NGOAPI - ##### dummySpend GET on Donation - fcn : queryAllDonations [2019-07-25T23:43:39.674] [INFO] NGOAPI - ##### dummySpend GET on Donation - args : {} [2019-07-25T23:43:39.675] [INFO] NGOAPI - ##### dummySpend GET on Donation - peers : peer1 [2019-07-25T23:43:39.675] [INFO] Connection - ============ START getClientForOrg for org Org1 and user michael

On the REST API App:
[2019-07-25T23:43:31.176] [ERROR] Connection - ##### getRegisteredUser - Failed to get registered user: michael with error: Error: Enrollment failed with errors [[{"code":20,"message":"Authorization failure"}]]

Then in Part 4 in npm start on ngo-ui

[ec2-user@ip-10-0-156-129 ngo-ui]$ npm start & [ec2-user@ip-10-0-156-129 ngo-ui]$ [email protected] start /home/ec2-user/non-profit-blockchain/ngo-ui ng serve --host 0.0.0.0 --port 8080 --disableHostCheck Schema validation failed with the following errors: Data path ".builders['app-shell']" should have required property 'class'. Error: Schema validation failed with the following errors: Data path ".builders['app-shell']" should have required property 'class'. at MergeMapSubscriber._registry.compile.pipe.operators_1.concatMap.validatorResult [as project] (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/src/workspace/workspace.js:215:42) at MergeMapSubscriber._tryNext (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:69:27) at MergeMapSubscriber._next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:59:18) at MergeMapSubscriber.Subscriber.next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:67:18) at MergeMapSubscriber.notifyNext (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:92:26) at InnerSubscriber._next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/InnerSubscriber.js:28:21) at InnerSubscriber.Subscriber.next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:67:18) at MapSubscriber._next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/map.js:55:26) at MapSubscriber.Subscriber.next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:67:18) at SwitchMapSubscriber.notifyNext (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/switchMap.js:86:26) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] start: ng serve --host 0.0.0.0 --port 8080 --disableHostCheck`
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:
npm ERR! /home/ec2-user/.npm/_logs/2019-07-25T23_29_49_177Z-debug.log`

Not sure if anybody else has encountered this? Btw - this is super great guide with video. Thanks for doing this.

Error on user not found

[2019-09-06T13:52:47.869] [INFO] NGOAPI - ##### New request for URL /health
[2019-09-06T13:52:47.924] [INFO] Connection - ##### getClient - Loading connection profiles from file: ../tmp/connection-profile/ngo-connection-prof[2019-09-06T13:52:47.926] [INFO] NGOAPI - ##### dummySpend - number of donation record: 53
[2019-09-06T13:52:47.927] [INFO] NGOAPI - ##### dummySpend - channelName : mychannel
ile.yaml and ../tmp/connection-profile/org1/client-org1.yaml
[2019-09-06T13:52:47.929] [ERROR] Invoke - Error: ##### getClient - User was not found : michael
at Object.getClientForOrg (/home/ec2-user/non-profit-blockchain/ngo-rest-api/connection.js:44:10)
at
[2019-09-06T13:52:47.929] [ERROR] Invoke - ##### invokeChaincode - Failed to invoke chaincode. cause:Error: ##### getClient - User was not found : michael
(node:28068) UnhandledPromiseRejectionWarning: Error: ##### invokeChaincode - Failed to invoke chaincode. cause:Error: ##### getClient - User was not found : michael
at Object.invokeChaincode (/home/ec2-user/non-profit-blockchain/ngo-rest-api/invoke.js:180:9)
at
(node:28068) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 55)

I get this error when curl to register new user.

Error when registering user on web UI

I've been unable to login or sign up on the web UI. It's giving me an error "Unknown Error. Ensure you are using HTTP, not HTTPS, to access the site." every time. I've tried removing the HTTPS in the url but it's giving me the same error. I know there's an open issue with user registration #60 but this seems to be the opposite of what that issue says.

How do I deploy my own app?

Hi,
I am a student who is working on a blockchain based project. I am using AWS Managed Blockchain for Hyperledger too. I want to know how do I deploy my own app instead of the NGO app?

Error while instantiating the ngo chaincode

[ec2-user@ip-172-31-92-163 ~]$ docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" -e "CORE_PEER_ADDRESS=$PEER" cli peer chaincode instantiate -o $ORDERER -C mychannel -n ngo -v v0 -c '{"Args":["init"]}' --cafile /opt/home/managedblockchain-tls-chain.pem --tls
2019-02-27 01:48:18.755 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-02-27 01:48:18.755 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: could not assemble transaction, err Proposal response was not successful, error code 500, msg instantiation policy violation: signature set did not satisfy policy

Step 1: Instantiate chaincode gets ACCESS DENIED error

Run the following command to instantiate the chaincode:

docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
   -e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" -e CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \
   cli peer chaincode instantiate -o $ORDERER -C $CHANNEL -n $CHAINCODENAME -v $CHAINCODEVERSION \
   -c '{"Args":["init","a","100","b","200"]}' --cafile $CAFILE --tls

gets the following error:

2020-08-10 14:31:52.975 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-08-10 14:31:52.975 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: error endorsing chaincode: rpc error: code = Unknown desc = access denied: channel [mychannel] creator org [m-FYY665VWURBD7EXONWLIKKSPBU]

I did peer chaincode list and I can see the chaincode.

I have followed the steps thoroughly. Thanks in advance for your help.

How to add delete method?

I add this function to the chaincode but the donor cannot be deleted.
Can you help me?
Thanks.

async deleteDonor(stub,args){
    console.log('============= START : queryDonor ===========');
    console.log('##### queryDonor arguments: ' + JSON.stringify(args));

    // args is passed as a JSON string
    let json = JSON.parse(args);
    let key = 'donor' + json['donorId'];
    console.log('##### deleteDonor key: ' + key);

    await stub.deleteState(key);
    console.log('============= END : deleteDonor ===========');
  }

Creating new client node stack for new member is impossible

./vpc-client-node.sh
Creating VPC - TODO. Create the VPC, subnets, security group, EC2 client node, VPC endpoint
Create a keypair

An error occurred (ValidationError) when calling the DescribeStacks operation: Stack with id None does not exist

An error occurred (ValidationError) when calling the DescribeStacks operation: Stack with id None does not exist
usage: aws [options] [ ...] [parameters]
To see help text, you can run:

aws help
aws help
aws help
aws: error: argument --network-id: expected one argument
Searching for existing keypair named -keypair
usage: aws [options] [ ...] [parameters]
To see help text, you can run:

aws help
aws help
aws help

Unknown options: -keypair
Creating a keypair named -keypair. The .pem file will be in your /home/ec2-user directory
usage: aws [options] [ ...] [parameters]
To see help text, you can run:

aws help
aws help
aws help
aws: error: argument --key-name: expected one argument
Keypair -keypair could not be created

preview access to hyperledger fabric

@MCLDG how long until preview access is granted for [email protected]? A couple of us have been allocated time/budget for POC work on hyperledger fabric, but the preview approval is taking awfully long. I'd be forever grateful if someone could give me an indicator of how long preview approval takes, so we can go work on something else, in the meantime, if it's going to take awhile.

Thanks!
JD

Unable to view console.log() logs printed in ngo.js

The console.log statements written in ngo.js are not getting printed.

I have tried multiple work arounds but cannot make it to work. please help, we are stuck.

  1. Redirected console.log() output to a file and overridden the console.log function a per the solution suggested here.
const util = require('util');
var fs = require('fs');
var log_file = fs.createWriteStream('ankurkhera.log', {flags : 'w'});
var log_stdout = process.stdout;

console.log = function(d) { //
  log_file.write(util.format(d) + '\n');
  log_stdout.write(util.format(d) + '\n');
};

  1. Tried using the shim.newLogger function and printed the logs but did not work.
const shim = require('fabric-shim');
var testLog = shim.newLogger('ankurkhera');
testLog.info('============= START : createSpend ===========')

  1. Tried looking at logs using docker command but nothing

docker logs -f cli

This is workaround code for my smart contract below

'use strict';
const shim = require('fabric-shim');
const util = require('util');

var testLog = shim.newLogger('ankurkhera');
var fs = require('fs');
var log_file = fs.createWriteStream('ankurkhera.log', {flags : 'w'});
var log_stdout = process.stdout;

console.log = function(d) { //
  log_file.write(util.format(d) + '\n');
  log_stdout.write(util.format(d) + '\n');
};

async createSpend(stub, args) {
    console.log('how are you'); //DOES NOT GET SAVED TO FILE
    testLog.info('============= START : createSpend ===========');// NO Logs
    testLog.info('============= END : createSpend ===========');
  }

When i call the createSpend() function, the console.log() do not get printed at all.

What is the peer name If we add two member

I set up hyperledger fabric network using single member in amazon manged blockchain. I have used this rest api. It worked properly. Then I added one more member follwoing this document. I have added endorsement policy as below,

docker exec cli peer chaincode instantiate -o $ORDERER \ 
-C ourchannel -n myjointcc -v v0 \
-c '{"Args":["init","a","100","b","200"]}' \
--cafile /opt/home/managedblockchain-tls-chain.pem --tls \
-P "AND ('Member1ID.member','Member2ID.member')"

Now I need to add peer of new member in this config file I have added like "peers":["peer1", "peer2"]. But I am getting the following error in REST Server.

[2020-09-02 05:54:20.915] [ERROR] invoke-chaincode - Error: Peer with name "peer2" not assigned to this channel
    at Channel._getTargets (/var/www/html/network/node_modules/fabric-client/lib/Channel.js:3515:13)
    at Channel.sendTransactionProposal (/var/www/html/network/node_modules/fabric-client/lib/Channel.js:2791:26)
    at Object.invokeChaincode (/var/www/html/network/app/invoke-transaction.js:41:31)
    at <anonymous>
[2020-09-02 05:54:20.915] [ERROR] invoke-chaincode - Failed to invoke chaincode. cause:Error: Peer with name "peer2" not assigned to this channel

Help me what peer name should I use here for peer of newly added member.

Error: "Does not understand PEM contents other than ECDSA private keys and certificates Please retry your request"

Im working though Part 6 in the tutorial and im seeing this issue when making a POST to the API Gateway

curl -s -X GET "$APIURL/donors"

This error does not occur when calling the lambda directly
aws lambda invoke --function-name $LAMBDANAME --payload "{\"fabricUsername\":\"$FABRICUSER\",\"functionType\":\"queryObject\",\"chaincodeFunction\":\"queryAllDonors\",\"chaincodeFunctionArgs\":{}}" --region $REGION

Error while running docker command in step 5

Hi,
I was following the non-profit-blockchain tutorial. When i run the docker command in step 5, I get the error. I think there a step missing.

[ec2-user@ip-10-0-69-111 ~]$ docker exec cli configtxgen -outputCreateChannelTx /opt/home/$CHANNEL.pb -profile OneOrgChannel -channelID $CHANNEL --configPath /opt/home/
Error response from daemon: Container ce08107bbe9a95d85994908c7c0eca61c6ff5279344d27fd2749bbcd3fd2579a is not running

DNS resolution failed while implementing API Server for Hyperledger Fabric Network using the AWS managed blockchain?

I have the Chiancode up and running over an EC2 instance. I would like to make my local machine as the API server.

Fabric Node side:
I kept the EC2 instance acting as the fabric Node side.

  • It has a connection profile, package.json, app.js. I created two javascript files, which were used to register and enroll admin, and then user1. The certificates were stored inside a wallet folder of the app folder.

I was able to accomplish API calling by running the app.js file that contains API methods for the chaincode running over the EC2 instance. The connection profile is same as the connection profile mentioned in the aws-samples for ngo application.

The template:

Here is the connection.yaml file

name: "Test"
x-type: "hlfv1"
description: "My Network"
version: "1.0"

channels:
  mychannel:
    orderers:
      - orderer.com
    peers:
      peer1:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true

organizations:
  Org1:
    mspid: %MEMBERID%
    peers:
      - peer1
    certificateAuthorities:
      - ca-org1

orderers:
  orderer.com:
    url: grpcs://%ORDERINGSERVICEENDPOINT%
    grpcOptions:
      ssl-target-name-override: %ORDERINGSERVICEENDPOINTNOPORT%
    tlsCACerts:
      path: %CAFILE%

peers:
  peer1:
    url: grpcs://%PEERSERVICEENDPOINT%
    eventUrl: grpcs://%PEEREVENTENDPOINT%
    grpcOptions:
      ssl-target-name-override: %PEERSERVICEENDPOINTNOPORT%
    tlsCACerts:
      path: %CAFILE%

certificateAuthorities:
  ca-org1:
    url: https://%CASERVICEENDPOINT%
    httpOptions:
      verify: false
    tlsCACerts:
      path: %CAFILE%
    registrar:
      - enrollId: %ADMINUSER%
        enrollSecret: %ADMINPWD%
    caName: %MEMBERID%

Fabric API Server: (local machine)
I am currently trying to call the API from my local machine by making it as the Fabric API server.
The things I did so far is as follows:

  1. I have copied the package.json, connection.yaml, wallet/User1 to the local machine
  2. I have modified the path or the certificates in the connection profile with respect to Fabric API server using

sed -i 's/localhost/[Fabric-Client-IP]/g' connection.yaml

  1. Added entries in /etc/hosts such that they will point to Fabric Client. {I feel I might be wrong with this configurations}
127.0.0.1 localhost
[Fabric-Node side-IP] orderer.com
[Fabric-Node side-IP] peer1

Here is an example of how I gave the IP for peer1 and orderer.com in the entries.

eg; 18.18.111.252 peer1
Once everything has been set up, I ran the app.js which ran at port 3000. While testing the api here using the local machine, I found few errors regarding DNS resolution.

{"error":{"message":"Unable to initialize channel. Attempted to contact 1 Peers. Last error was Error: 14 UNAVAILABLE: DNS resolution failed","stack":"Error: Unable to initialize channel. Attempted to contact 1 Peers. Last error was Error: 14 UNAVAILABLE: DNS resolution failed\n    at Network._initializeInternalChannel (/home/Desktop/app/node_modules/fabric-network/lib/network.js:119:12)\n    at <anonymous>"}}

I wonder where might be the issues over the configurations I attempted. Kindly advice. Thanks.

Cannot read property 'curve' of undefined

Hi, @MCLDG !

I have started the non-profit-blockchain example project for about a week.

Today I checked the project and I found that something went wrong with the users certificates. Each request to the network returns:

##### getRegisteredUser - Got admin property [ { username: 'admin', secret: 'Adminpwd1!' } ]
[FileKeyValueStore.js]: getValue { key: 'admin' }
[crypto_ecdsa_aes]: importKey - start
[crypto_ecdsa_aes]: importKey - have the key [Circular]
[utils.CryptoKeyStore]: This class requires a CryptoKeyStore to save keys, using the store: {"opts":{"path":"/tmp/fabric-client-kv-org1"}}
[FileKeyValueStore.js]: constructor { options: { path: '/tmp/fabric-client-kv-org1' } }
[utils.CryptoKeyStore]: _getKeyStore returning ks
[FileKeyValueStore.js]: getValue { key: '8f59ca67beed7dbdfe431df07ce5b2bb900088d118d37a3425af91f8e5f84a61-priv' }
[FileKeyValueStore.js]: getValue { key: '8f59ca67beed7dbdfe431df07ce5b2bb900088d118d37a3425af91f8e5f84a61-pub' }
error: [Client.js]: Failed to load user "admin" from local key value store. Error: TypeError: Cannot read property 'curve' of undefined
##### getRegisteredUser - Failed to get registered user: user101 with error: TypeError: Cannot read property 'curve' of undefined

I thought that the certificates for admin and user1(for example) are expired, but after I checked the list of certificates I had marked that they should not have expired:

        Issuer: C=US,ST=Washington,UnknownOID=2.5.4.7,O=Amazon Web Services, Inc.,OU=Amazon Managed Blockchain,CN=member Amazon Managed Blockchain Root CA
        Validity
            Not Before: Jun 20 17:40:00 2019 UTC
            Not After : Jun 17 17:45:00 2029 UTC
        Subject: C=US,ST=North Carolina,O=Hyperledger,OU=client,OU=member,CN=admin

Can you give me an advice how to resolve this issue?
Thanks!

PART2: STEP3 - Error in instantiation of ngo chaincode which is in nodejs

image

[ec2-user@ip-10-0-51-98 ~]$ docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
>     -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" -e "CORE_PEER_ADDRESS=$PEER"  \
>     cli peer chaincode instantiate -o $ORDERER -C mychannel -n ngo -v v0 -c '{"Args":["init"]}' --cafile /opt/home/managedblockchain-tls-chain.pem --tls

2020-07-03 07:01:23.122 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-07-03 07:01:23.122 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: could not assemble transaction, err Proposal response was not successful, error code 500, msg instantiation policy violation: signature set did not satisfy policy``

Facing this error when trying to instantiate any node.js chaincode, golang chaincodes are running fine. What should I do ?

Errors when generating configtx channel configuration

Hello, I got this issue several times ,when I am about to generate the configtx channel configuration. By executing this command :

docker exec cli configtxgen -outputCreateChannelTx /opt/home/$CHANNEL.pb -profile OneOrgChannel -channelID $CHANNEL --configPath /opt/home/

Error Preview

Usually, I would restart everything from zero, and redo it if it happens and hopefully the problem doesn't show up, but :

  1. Could anybody tell me what this error means?
  2. How would I prevent this problem from happening?
  3. Some references would mean a lot. ๐Ÿ‘ I really want to learn what is causing this problem.

Thank you!

Add another member in API

Hello, I am trying to create a network using your example as a guide. I have 4 members (all in my account for testing purposes), I will call them A, B, C, D. I have 2 channels, the first one has A and B and the second one has A, C, and D. I'm kind of confused how to set up these channels and members in the API. How can I do this?

Thank you

UI application error

Part4 : User Interface
step5

I cannot loggin because I don't have a User.
So I try to Sign up,
but I cannot Sign up
because any Name and Email already in use.

Why happens this situation and
do you think where do I make mistakes?

done
RUN REST API

[ec2-user@ip-10-0-95-83 ngo-rest-api]$ curl -s -X GET   "http://localhost:3000/donors" -H "content-type: application/json"
[{"donorUserName":"braendle","email":"[email protected]","registeredDate":"2018-11-05T14:31:20.182Z","docType":"donor"},{"donorUserName":"edge","email":"[email protected]","registeredDate":"2018-10-22T11:52:20.182Z","docType":"donor"},{"donorUserName":"edge2","email":"[email protected]","registeredDate":"2018-10-22T11:52:20.182Z","docType":"donor"},{"donorUserName":"jane","email":"[email protected]","registeredDate":"2018-10-21T09:52:20.182Z","docType":"donor"},{"donorUserName":"louisa","email":"[email protected]","registeredDate":"2018-11-18T05:32:20.182Z","docType":"donor"}]

On Cloud9
~/non-profit-blockchain/ngo-ui/src/environments/environment.ts

export const environment = {
  production: false,
  host: '',
  port: '',
  dbhost: '',
  dbport: '',
  api_url: 'http://ngo-fabri-Blockcha-1EJ5V39CGSNLJ-153937679.us-east-1.elb.amazonaws.com/',
  test: 'test',
  socket_url: 'ws://ngo-fabri-Blockcha-1EJ5V39CGSNLJ-153937679.us-east-1.elb.amazonaws.com'
};

~/non-profit-blockchain/ngo-rest-api/ngo-load-workshop.sh

...
export ENDPOINT=ngo-fabri-Blockcha-1EJ5V39CGSNLJ-153937679.us-east-1.elb.amazonaws.com
export PORT=80
...

Step1: Client node can't be created

The client node creation fails at BlockchainWorkshopEC2 with the error
The image id '[ami-0434d5878c6ad6d4c]' does not exist (Service: AmazonEC2; Status Code: 400; Error Code: InvalidAMIID.NotFound; Request ID: 431a4359-ad9d-45e7-b45f-95a6981ee1ff)

Looks like the id is hardcoded into the project, is this a temporary issue or how can I fix this?

ExecuteQuery not supported for leveldb

I have this deployed up on the starter version of the managed blockchain. I'm getting this error when I try to run the 'queryAllDocuments' command. Command is below along with the error response. Is this something thats just outdated/no longer supported, or is this something that I'm doing wrong?

docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem"     -e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH"     cli peer chaincode query -C $CHANNEL -n $CHAINCODENAME -c '{"Args":["queryAllDocuments"]}'
Error: endorsement failure during query. response: status:500 message:"transaction returned with failure: Error: GET_QUERY_RESULT failed: transaction ID: c74b266961c8d5c2c8e495d117f027fd856fc7e543ed2b9f34ad09508a7a2494: ExecuteQuery not supported for leveldb" 

Post creation blank website fix

Hello,
After completing the 5th step my website was just showing blank, it was hard to tell what was wrong.
after confirming I completed all the steps correctly I found out that there is a bug. you need to add: "import 'core-js/es7/reflect';" to src/polyfills.ts !!
after that, I was able to see and use the website.

Endorsement failure during invoke

Thanks for writing this tutorial. It's been very helpful in setting up AWS blockchain.
I am currently running a two org fabric network with one peer in each member. I was able to add the second member to a channel and install and instantiate a chaincode. After add the second org and updating the endorsement policy the queries work fine but for some reason I can't invoke the chaincode from either org.

I get following error from invoking the ngo chaincode

docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem"     -e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH"     cli peer chaincode invoke -C mychannel -n ngo     -c  '{"Args":["createDonor","{\"donorUserName\": \"edge\", \"email\": \"[email protected]\", \"registeredDate\": \"2018-10-22T11:52:20.182Z\"}"]}' -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls
Error: endorsement failure during invoke. chaincode result: <nil>

Can you please help understand what am I doing wrong?

Error when registering a user in the UI

Update the documentation to explain how to resolve a common error when registering a user in the UI. Sometimes an error is showing indicating the user cannot be registered, explaining that HTTPS and not HTTP should be used. The console (F12) shows a CORS issue. All of this is misleading. The issue is caused by the URL of the ELB not being updated in src/environments/environment.ts

Error deploying node chaincode

I realize this sample deploys GO chaincode. I used this as a setup guide to deploy node but after the new release i am getting a npm registry error when trying to deploy chaincode written in node:

Error: could not assemble transaction, err Proposal response was not successful, error code 500, msg failed to execute transaction<TRANSACTION_ID>: error starting container: error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "npm ERR! code ENOTCACHED npm ERR! request to https://registry.npmjs.org/@types%2fgoogle-protobuf failed: cache mode is 'only-if-cached' but no cached response available.

If anyone knows how to fix this or has any insight !

Error when attempting to start the application

When I attempt to run the node application from last Step-4 of Part-4, I'm getting the following error. Any help would be much appreciated. I've followed your steps to the letter, and this was the final step to get things up and running.

cloud9-ide-admin:~/non-profit-blockchain/ngo-ui (master) $ 
> [email protected] start /home/ec2-user/non-profit-blockchain/ngo-ui
> ng serve --host 0.0.0.0 --port 8080 --disableHostCheck

Schema validation failed with the following errors:
  Data path ".builders['app-shell']" should have required property 'class'.
Error: Schema validation failed with the following errors:
  Data path ".builders['app-shell']" should have required property 'class'.
    at MergeMapSubscriber._registry.compile.pipe.operators_1.concatMap.validatorResult [as project] (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/src/workspace/workspace.js:215:42)
    at MergeMapSubscriber._tryNext (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:69:27)
    at MergeMapSubscriber._next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:59:18)
    at MergeMapSubscriber.Subscriber.next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:67:18)
    at MergeMapSubscriber.notifyNext (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:92:26)
    at InnerSubscriber._next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/InnerSubscriber.js:28:21)
    at InnerSubscriber.Subscriber.next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:67:18)
    at MapSubscriber._next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/map.js:55:26)
    at MapSubscriber.Subscriber.next (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:67:18)
    at SwitchMapSubscriber.notifyNext (/home/ec2-user/non-profit-blockchain/ngo-ui/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/switchMap.js:86:26)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `ng serve --host 0.0.0.0 --port 8080 --disableHostCheck`
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:
npm ERR!     /home/ec2-user/.npm/_logs/2019-11-10T14_49_16_727Z-debug.log
^C
[1]+  Exit 1                  npm start
cloud9-ide-admin:~/non-profit-blockchain/ngo-ui (master) $ node -v
v8.16.2

Policy error on attempting to upgrade chaincode

I am getting the following policy error when trying to upgrade changes to my chaincode:

Error: could not assemble transaction, err Proposal response was not successful, error code 500, msg instantiation policy violation: signature set did not satisfy policy

This was the command I used, and none of the local variables had changed since installation and instantiation of the original chaincode.

docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" -e "CORE_PEER_ADDRESS=$PEER" cli peer chaincode upgrade -o $ORDERER -C mychannel -n ngo -v 2.0 -c '{"Args":[""]}'

Error signing new channel configuration

Hello, first of all, great tutorial, it's helping me a lot!

I'm facing a problem when trying to sign the new channel configuration. When I try to run the command in step 10 in part 5 the following error occurs:

2019-06-15 23:35:05.173 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Error: proto: can't skip unknown wire type 6 for common.Envelope

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.