fabric-samples | Samples for Hyperledger Fabric | Blockchain library
kandi X-RAY | fabric-samples Summary
kandi X-RAY | fabric-samples Summary
You can use Fabric samples to get started working with Hyperledger Fabric, explore important Fabric features, and learn how to build applications that can interact with blockchain networks using the Fabric SDKs. To learn more about Hyperledger Fabric, visit the Fabric documentation.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Main program .
- write values to database
- Adds a bid to the network
- BEGIN bidder
- recursive function to process blocks
- Close the auction
- End the auction for a particular auction
- submit a ticket
- Initialize OAuth2 client .
- Initialize a contract client .
fabric-samples Key Features
fabric-samples Examples and Code Snippets
Community Discussions
Trending Discussions on fabric-samples
QUESTION
I'm running chaincode-java from fabric-samples.
...ANSWER
Answered 2022-Feb-17 at 17:49Bit of background first; the ContractAPI that is available in Java, Go and Typescript is used to generate a 'model' of the overall contract including the data type that be passed and returned from transaction functions. (JavaScript supports a limited subset to the extent possible based on it's typing).
In order to support this there has to be a 'serializer' of some sort to process the data. The underlying chaincode API of just 'invoke(byte[]): byte[]' gives the developer the power to serialize how they wish though not all of us need to use that power.
There is a default 'serializer' in the ContractAPI; this can be swapped out if needed.
To specifically answer the question;
The return types can be:
- strings,
- numbers (for Java this is any of the primitive 'number' types)
- booleans,
- other types that have been annotated.
- arrays of the above
For the 'other types', there are annotations that can be used to define types that can also be passed to and from the transaction functions.
You might see something like this:
QUESTION
Hyperledger Fabric version: 2.2.4
Fabric Client: Fabric-Tools 2.2 Docker Image - https://hub.docker.com/layers/hyperledger/fabric-tools/2.2/images/sha256-a5f691808466e90942af3f5f72d697cdaa4e545acfc1f645a553986423ef7ea5?context=explore
Chaincode: Fabric-samples Javascript
Context on the issue:
I am currently creating a CI/CD pipeline for the deployment of chaincode using the 2.x chaincode lifecycle. I am facing unexpected behavior with Node.js chaincode deployment whereby the node_modules I install using npm install prior to running peer lifecycle chaincode package
(per the documentation) are not included in the resulting tar.gz package within code.tar.gz. Because my peer nodes are not able to access the internet to install dependencies, the missing modules result in errors when running the chaincode after installation. More specifically, I get errors related to missing modules like Fabric Shim which are defined in require()
statements in the chaincode sample.
When manually deconstructing unpacking the tar.gz structure, the code.tar.gz archive does not include node_modules that are present in the target chaincode directory that I defined the path to in the peer lifecycle chaincode package
command.
Expected Behavior: My understanding was that the new chaincode lifecycle packaging process included the dependencies in the tar.gz package before deploying and therefore there is no need to run npm install or otherwise download dependencies from externally at runtime. More specifically, based on the documentation and examples online, it seems the peer lifecycle chaincode package command would include installed dependencies from node_modules in the package for deployment.
Is this not the default behavior of the chaincode packaging mechanism, and if not, is there a best practice for bundling dependencies on Node.js chaincode where npm install
at the peer is not possible?
TIA for any help here
...ANSWER
Answered 2022-Jan-24 at 23:58The peer lifecycle chaincode package explicitly excludes the node_modules directory. Also as I assume you are currently using the inbuilt docker builder and launcher of the peer, even if you did send a package that contained the node_modules directory, it will still call npm install
on it even with the presence of the node_modules directory and may end up trying to interact with an external npm registry.
I would suggest that you look at either using a chaincode external builder and launcher, see https://hyperledger-fabric.readthedocs.io/en/release-2.2/cc_launcher.html and you could process a chaincode package that already has the node_modules included. A chaincode package is just a tar.gz file so is easy to package yourself as described in the link
or use chaincode as a service https://hyperledger-fabric.readthedocs.io/en/release-2.2/cc_service.html which doesn't require any code to be packaged and processed by the peer.
QUESTION
I am trying to pass sensitive data of clients to the chaincode function as given in the private data example of Hyperledger Fabric. The documentation recommends to pass sensitive data as --transient
data field and parse the transient map in the chaincode function execution:
ANSWER
Answered 2022-Jan-19 at 10:33Yes, the endorsing peer can see transient data within a transaction proposal that it receives. Best practice is to only send proposals containing private data to peers belonging to organisations that should be able to see that private data.
If you are using Hyperledger Fabric v2.4+ and the Fabric Gateway client APIs, this is taken care of for you. If you are using an older version of Fabric or continuing to use the legacy SDKs, you may need to explicitly specify the endorsing organisations or peers.
Just one other clarification is that the transient data itself is not stored anywhere. If the transaction function writes that transient data to a private data collection then the written data is recorded in that private collection, stored only on peers of organisations that are members of the collection. Similarly, if the transaction function writes any of that transient data to the ledger or returns it in the transaction response, those values will be recorded on the ledger when the transaction is committed.
QUESTION
I am trying to set up a hyperledger fabric on raspberry pi 4. I tried many ways but I always get unable to download latest or any hyperledger fabric binaries or " platform specific fabric binary is not available to download". for example the result is like this:
Clone hyperledger/fabric-samples repo
===> Cloning hyperledger/fabric-samples repo Cloning into 'fabric-samples'... remote: Enumerating objects: 9101, done. remote: Counting objects: 100% (29/29), done. remote: Compressing objects: 100% (14/14), done. remote: Total 9101 (delta 13), reused 19 (delta 11), pack-reused 9072 Receiving objects: 100% (9101/9101), 5.14 MiB | 676.00 KiB/s, done. Resolving deltas: 100% (4855/4855), done. fabric-samples v2.4.0 does not exist, defaulting to main. fabric-samples main branch is intended to work with recent versions of fabric.
Pull Hyperledger Fabric binaries
===> Downloading version 2.4.0 platform specific fabric binaries ===> Downloading: https://github.com/hyperledger/fabric/releases/download/v2.4.0/hyperledger-fabric-linux-aarch64-2.4.0.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 9 100 9 0 0 22 0 --:--:-- --:--:-- --:--:-- 22
gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now ==> There was an error downloading the binary file.
------> 2.4.0 platform specific fabric binary is not available to download <----
I tried so many ways but I always ended up with a fabric-sample folder that has no bin or fabric binary. Does anyone did have the same trouble and fixed it? Please help. Thank You
...ANSWER
Answered 2021-Dec-16 at 10:30The platforms for Hyperledger Fabric and available images are listed in the releases page
We don't build for any ARM based device. Though we do know members of the community have done this; I don't know what the 'state-of-the-art' is.
QUESTION
My problem is that i get an Error while trying to use the chaincode for the test-network but running my application instead of the application-javascript provided at fabric-samples/asset-transfer-basic.
The steps that I follow are:
...ANSWER
Answered 2021-Nov-17 at 09:38You have peer discovery disabled in your code, usually, you do it when you specify peers you want to connect to but since you don't do it - the SDK client just didn't know to what peers it should connect so it connected to none of them, got 0 responses and threw an error. So I changed this line from your example:
QUESTION
I'm trying to run the sample test-network from the fabric-samples folder, but for some reason the chaincode installation fails, giving me an error. Here's all I get when trying to run the deployCC
command:
ANSWER
Answered 2021-Oct-23 at 10:23The problem is that the test-network uses the inbuilt chaincode builder and launcher which requires access to your docker on windows setup. The error being reported is that it cannot connect to it.
If you are using the main branch of fabric-samples then can try to set the DOCKER_SOCK environment variable before bringing up the test-network in your window shell. Take a look at https://docs.docker.com/desktop/faqs/ to see what you can set it to. Also look at the option to expose the docker daemon on an unsecure port which might help.
The DOCKER_SOCK option was added to fabric-samples in main but doesn't appear to be in the 2.2 branch so be aware you aren't using a fabric LTS release here
The caveat is I've not tried this so no guarantees it will work
Unfortunately Windows is not given much attention at the moment for using fabric so the best advice I can give you at this time would be to use linux instead as your platform (you can use WSL2 but you should google installing docker into a WSL2 distro as it does require a bit of extra work)
QUESTION
I created a chaincode and deployed it on the test network. I call the transactions from command line.
...ANSWER
Answered 2021-Oct-20 at 09:31I would suggest adding --waitForEvent
to each of the invoke commands otherwise you aren't waiting for the transaction to be committed to the ledger, so subsequent invokes may not see the results of previous invokes
QUESTION
By looking at chaincode-java and chaincode-go in https://github.com/hyperledger/fabric-samples/tree/main/asset-transfer-basic, I find the java implementation requires annotations like @Transaction
and @Contract
, while the Go one does not.
As in Java, I can use @Contract(name)
to change contract name, how would I do so in Go?
If Go doesn't need @Transaction(intent)
, why does Java require it?
ANSWER
Answered 2021-Aug-27 at 09:33Go does not support annotations. fabric-contract-api-go
turns into an accessible operation every public method that has a smart contract as receiver and uses reflection to build metadata and such kind of things (from v2.X).
Java supports annotations. Reflection in Java works in a different way than in Go and its performance is really poor. Thus, annotations are preferred.
Languages differ from each other in many things apart from its syntax.
And about chaincode name, you specify your preferred name and version number when packaging your Go chaincode. It does not depend on the source code.
QUESTION
I'm trying to invoke a chaincode function that sets details about a crop.
This function doesn't use date/time, and is logically deterministic. I've checked that the chaincode is successfully installed for each organization of the channel and committed to the channel using peer lifecycle chaincode queryinstalled
and peer lifecycle chaincode querycommitted
.
However, when I run peer chaincode invoke
, it yields an error Error: could not assemble transaction: ProposalResponsePayloads do not match
.
There was a broader question that covered some common causes of error, but I'm not completely sure if any of the reasons listed are applicable in my case (Hyperledger Fabric: Error: could not assemble transaction: ProposalResponsePayloads do not match).
This was the invoke command:
...ANSWER
Answered 2021-Jun-28 at 05:49try to use only one peer to endorsement,like these:
QUESTION
I just reinstalled Fabric Samples v2.2.0 from Hyperledger Fabric repository according to the documentation.
But when I try to run asset-transfer-basic
application located in fabric-samples/asset-transfer-basic/application-javascript
directory by running node app.js
the wallet is created and an admin and user is registered. But then it tries to invoke the function as given in app.js
and shows this error
ANSWER
Answered 2021-Jan-29 at 04:04In my opinion, the CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE
setting seems to be wrong.
you can check docker-compose.yaml
or core.yaml
- I will explain fabric-samples/test-network as targeting according to your current situation.
- You can check in
CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE
in docker-compose.yaml - Perhaps in your case(fabric-samples/test-network), the value of
${COMPOSE_PROJECT_NAME}
was not set properly, so it was set to_test
. - Make sure the value is set correctly and change it to your network name.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fabric-samples
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page