Hyperledger Fabric invokeChaincode - hyperledger-fabric

I want to invoke another chaincode inside a chaincode using ctx.stub.invokeChaincode("called chaincode name", ["the name of the function (transaction) of the called chaincode", args]), and my both chaincodes has been instantiated on the same channel, but I get the following error:
Calling chaincode Invoke() returned error response [Error: You've
asked to invoke a function that does not exist: Confirm.confirmData].
Sending ERROR message back to peer.
I am not sure if I am wrong with defining the list chainCode arguments.

Related

In Fabric Ledger ,Contract is not called

I deploy a java chaincode in "fabric-sample" testnetwork. All the life cycles are sucessfully executed like (peer clifecycle chaincode package|install|approve|commit).After that chaincode is instantiaed successfully.But when try to access the chain code functions, I get the below error :
**Error: endorsement failure during invoke. response: status:500 message:"Undefined contract called" **
I used the below code to access chain code function "addNewCar" and get the following error :
The "Undefined contract called" message is returned by the Java chaincode runtime if the contract namespace specified does not exist within the chaincode. A chaincode may contain multiple smart contract definitions, each identified by a namespace. It may also contain one default smart contract, which does not have a namespace (or whose namespace is empty).
Just for reference, and by way of explanation, programmatically in a Java client application you would obtain the default smart contract for a chaincode by calling Network.getContract(String chaincodeName). You would obtain a specific named (or namespaced) smart contract within a chaincode by calling Network.getContract(String chaincodeName, String contractName).
When actually invoking the chaincode, the contract name (or namespace) is prepended to the transaction function name so that the chaincode runtime can identify which smart contract should be invoked. The actual transaction name passed to invoke the AddCar transaction function on a smart contract named car would be car:AddCar. The AddCar transaction on the default (no namespace) smart contract would be invoked just using the name AddCar.
Using the peer CLI command, you need to prepend the correct smart contract name to your transaction function name in order to invoke a specific named smart contract. Your screenshot does not capture the complete CLI command you invoked but I suspect that the transaction function name you supplied does not correctly include the name of the smart contract providing that transaction function.

Failed to catch a chaincode event when the the first chaincode who set the event is invoked by a second chaincode

I'm trying to catch an event payload from a chaincode A deployed in my infra, when I tried to catch the event payload directly from the chaincode A, it works, but when I try to catch the same event payload when a chaincode A is invoked by another chaincode B, it doesn't work. Any help ?
In the latest fabric documentation, the limitation is described that only the top level chaincode can call setEvent to register a chaincode event.
https://hlf.readthedocs.io/en/latest/developapps/transactioncontext.html#stub

Implementing Private Data Collection in Hyperledger Fabric 2.0 Error

I tried to implement the private data collections in fabric 2.0 network.I have faced error when I tried to invoke chaincode with the transient data flag.
And it is unable to recognize the method ("priv").
Error: endorsement failure during invoke. response: status:500 message:"error in simulation: transaction returned with failure: Error: You've asked to invoke a function that does not exist: priv"
The "priv" method in chaincode is fairly simple.It is using the putPrivateData() method to store the private data.
I have fixed it.The issue was related to the version of shim api in package.json of chaincode.

Error while using node js sdk in hyperledger fabric?

I m using node sdk for hyperledger fabric.i got the below error while using apiserver.js file in sdk. It only happens if i excute same query multiple time.
2019-11-22T09:02:35.721Z - warn: [Query]: evaluate: Query ID "[object Object]" of peer "peer0.org1.example.com:7051" failed: message=transaction returned with failure: TypeError: Assignment to constant variable., stack=Error: transaction returned with failure: TypeError: Assignment to constant variable.
at self._endorserClient.processProposal (/home/cybrosys/VIRUS/ERC-20-with-Hyperledger-Fabric/fabcar/javascript/node_modules/fabric-client/lib/Peer.js:140:36)
at Object.onReceiveStatus (/home/cybrosys/VIRUS/ERC-20-with-Hyperledger-Fabric/fabcar/javascript/node_modules/grpc/src/client_interceptors.js:1207:9)
at InterceptingListener._callNext (/home/cybrosys/VIRUS/ERC-20-with-Hyperledger-Fabric/fabcar/javascript/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/home/cybrosys/VIRUS/ERC-20-with-Hyperledger-Fabric/fabcar/javascript/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/home/cybrosys/VIRUS/ERC-20-with-Hyperledger-Fabric/fabcar/javascript/node_modules/grpc/src/client_interceptors.js:845:24), status=500, , url=grpcs://localhost:7051, name=peer0.org1.example.com:7051, grpc.max_receive_message_length=-1, grpc.max_send_message_length=-1, grpc.keepalive_time_ms=120000, grpc.http2.min_time_between_pings_ms=120000, grpc.keepalive_timeout_ms=20000, grpc.http2.max_pings_without_data=0, grpc.keepalive_permit_without_calls=1, name=peer0.org1.example.com:7051, grpc.ssl_target_name_override=peer0.org1.example.com, grpc.default_authority=peer0.org1.example.com, isProposalResponse=true
Help will be appreciated!
The error you are receiving is tunneled from the chaincode to the sdk.
Essentially is not related to the SDK but the chaincode.
Go to the machine with Hyperledger installed, and open logs for the dev peer.
You will find the same error
[Query]: evaluate: Query ID "[object Object]" of peer "peer0.org1.example.com:7051" failed: message=transaction returned with failure: TypeError: Assignment to constant variable., stack=Error: transaction returned with failure: TypeError: Assignment to constant variable.
and you will get that the problem is related to the chaincode.
I don't know how did you write your contract, if Go or other languages, but the message is clear: you declared a const and you are assinging it a new value.
Check your code, re-deploy the contract and you solve.

Error reading from stream

JIRA issue: https://jira.hyperledger.org/browse/FAB-7420
I'm trying to set up a network of four organisations, each with one peer (set as admin), and an orderer with kafka ordering service along with a client, which makes 7 VMs.
Setting up the cryptographic material, starting every channel (two of them), joining them with the appropriate peers and installing/instantiating chaincode happens with no trouble.
When trying to invoke chaincode, the chaincode can be successfully invoked (status:200) however the results do not seem to be recorded on the ledger. When running chaincode which returns the value for a/multiple key(s), the resulting payload is simply null. This seems to be due to a fault in the ordering service: I get keeping the error message "Error reading from stream: rpc error: code = Canceled desc = context canceled".
Here are logs for the orderer and endorsing peers of the transaction (which returns status:200)
Orderer: https://gist.github.com/alexanderlhicks/91f32fb5ed2b6d5d232dcdad0572ffee
Peer1 (initiating transaction): https://gist.github.com/alexanderlhicks/a2c7a37d3e692336dbc9a8a9f7fd66ba
Peer2 (has the chaincode installed): https://gist.github.com/alexanderlhicks/75c76b11a26963d7a6962f51295ea816
Peer3 (on channel but does not have that chaincode installed): https://gist.github.com/alexanderlhicks/951757e880d8c2f658d2d188e25b9274
What could be causing the "Error reading from stream" message which seems to be the only error happening? I'm tried playing around with peer and orderer configurations but to no avail. Searching for this error also returns issues in channel creation, or joining channels, which I assume has gone fine since I can invoke chaincode on the channels with my peers.
The txid in the logs is 61f54319421bae9c47fab505e502b932ff6c6b58d7d3795afe1400466e663a5d.
Cheers.

Resources