The Retailer should run the following commands in their Cloud9 terminal.
The blockchain network is hosted in a VPC that is managed by AWS. For security
reasons, the peer nodes in this VPC don’t have direct access to the Internet,
which means that they are not able to install the dependencies declared in your
package.json
file. For this reason, we have downloaded the dependencies in
your Cloud9 IDE and bundled them with your project using
browserify. To prevent the chaincode installation from
failing when looking for external dependencies, we’ll need to overwrite our
package.json
file with the following JSON code, which removes references to
external dependencies. Overwrite the contents of your package.json
file in
your Cloud9 environment with the following text. Be sure to save the file.
{
"name": "chaincode",
"version": "1.0.0",
"scripts": {
"start": "node products.js"
},
"dependencies": {
"fabric-shim": "^1.2.4"
}
}
Next we need to build the chaincode into a package that will be identical for all peers. The following code packages the chaincode and uploads to package to the shared S3 bucket created earlier.
cd ~/environment/chaincode
rm -rf node_modules
rm package-lock.json
cd ..
cp -r chaincode ~
cd
docker exec cli peer chaincode package supplychaincc.tar -n supplychaincc -v v0.1 -l node -p /opt/home/chaincode
sudo cp $HOME/fabric-samples/chaincode/hyperledger/fabric/peer/supplychaincc.tar $HOME
sudo chmod 644 supplychaincc.tar
aws s3api put-object --bucket $BUCKET_NAME --key supplychaincc.tar --body $HOME/supplychaincc.tar --acl bucket-owner-full-control
sudo rm supplychaincc.tar
cd