How to package the couchdb indexes in external chaincode build? - couchdb

I am trying to install and deploy the chaincode as external service following the instructions here
I have created the couchdb indexes following the instructions here and package the chaincode as:
package the META-INF directory along with the connection.json which outputs "code.tar.gz"
package the META-INF directory along with "code.tar.gz" and "metadata.json" which outputs "cc_name.tgz"
Both of these methods resulted in error while installing the chaincode using peer lifecycle command.
I installed the chaincode without packaging the META-INF (couchd indexes) and everything works as expected. But for blockchain application I have few situations where I need to query data from couchdb and update the assets in the ledger.
What's the correct way to package the couchdb indexes when deploying the chaincode externally?

Inside code.tar.gz:
mychaincode#0.0.1.tar.gz -> code.tar.gz-> META-INF/statedb/couchdb/indexes/myindex.json.
Anyway, I would advise to use IBM Blockchain Platform VSCode extension to ease the packaging and other kind of operations.
To make use of your indexes, use use_index in your rich queries (https://docs.couchdb.org/en/3.1.1/api/database/find.html).

Related

issues with installing fabric samples

some files are missing from the Fabric samples, docker images, and binaries download like the first-network folder and others. how do I get the missing files imported on vscode?
At the time of writing, first-network no longer exists as a Hyperledger Fabric sample. If you are using an old versions of Fabric (for example, v1.4) and the corresponding documentation, which does describe first-network, you will need to make sure you specify the appropriate version when installing Fabric components so it pulls the samples from the correct branch of the samples repository. For Fabric v1.4, that would be this branch:
https://github.com/hyperledger/fabric-samples/tree/release-1.4
If you are using the latest version of the Fabric and its documentation, test-network is now used to deploy a sample network and chaincode.

hyperledger composer, where are business network stored

I has been deployed (this awesome deprecated tool named) hyperledger composer. After a couple of days working, click on a network card emit an error and I'm unable to login. After give up, reinstall everything from zero, does not remove this cards. Already deleted ~/compose* files, also teardown fabric and docker containers.
So my problem have two solutions:
One, find where are composer model and scripts stored to recover.
Two, fix and/or remove these files.**
Question: Where are CTO and js script files stored?
I will suggest you not to you use Composer as it is has been deprecated. Please read here. https://github.com/hyperledger/composer/blob/master/README.md

Hyperledger fabric with node gives me You've asked to invoke a function that does not exist

I created a chaincode in hyperledger fabric using the "first-network" as a local blockchain to deploy my contract, I tested it, it worked great, loved it, and then I decided to add a new method to my contract, nothing complex, a simple query.
My program is in node with typescript, so I deleted the dist folder, run npm run build and the ./byfn.sh down script even deleted all my containers and images and started all back using the ./byfn.sh up script and no matter what've tried I'm getting this error:
You've asked to invoke a function that does not exist: queryTransference
Failed to submit transaction: Error: Endorsement has failed
So I thougth maybe I'm doing something wrong, so I added my methods to the fabcar.ts example and started the fabric again to run the fabcar with both the fabcar methods and mine, and this time, I'm getting the same error for all my methods, while the original methods from the fabcar example are the only ones recognized.
So, where is fabric storing the old versions of the code? I'm deleting all dist folder, node_modules, containers and images, how come it doesn't update the contract if I'm publishing in a brand new blockchain? do I need to increase versions even in development each time I change something?
Thanks

How to place chaincode using hyperledger fabric?

Problem:
I am very new to Hyperledger Fabric. I have cloned the fabric-samples repository and built a network using it. The problem I have is, should I place chaincode inside the chaincode folder of the fabric-samples?.
Yes, you should if you are using the examples but you can change the path as you like.
I recommend you to read the documentation first.
Choosing a Location for the Code

Hyperledger Fabric: UI for first-network

I am quite new to Hyperledger Blockchain and have started with exploring 2 sample codes.
(1) https://medium.freecodecamp.org/ultimate-end-to-end-tutorial-to-create-an-application-on-blockchain-using-hyperledger-3a83a80cbc71 - where creating an application using hyperledger was taught - through creating .bna, .card files, deploying them etc. Also saw that an Angular extension is supported, giving the UI.
(2) Classic first-network http://hyperledger-fabric.readthedocs.io/en/release-1.1/build_network.html - where chaincode was deployed etc.
My question is, how can I get a UI for (2),like I did in (1)? It was quite convenient.
In the First tutorial, you used Hyperledger Composer to create a BNA which is a friendly way to create chaincode, and there is an Angular Application generator included.
In the second you directly installed some chaincode on to Fabric without a UI (and without using Composer. In this case you would have to write the UI yourself. In the first example you can build your own app by extending the generated app.
Composer is a tool that makes it easy and fast to create chaincode and applications to run on Fabric. If you don't use Composer you do have some more flexibility, but you have to do more work yourself.

Resources