calling a methods chaincode from a different method in the same chaincode #fabric-chaincode


Marek Malik <info@...>
 

Hello Guys, 

Just a quick question. 

I have this scenario where I'm calling one method inside a chaincode A (let's say to update some properties based on external factors). Now, these external factors are being returned by a second method inside the same chaincode. I'm trying to call this method using the contract api interface using the Stub (invokeChaincodeWithStringArgs). But I'm getting an error on the execution of that call. Is there any possibility to make such call or there is some limitation and I need to create a new chaincode for that second method?

I have encapsulation inside the chaincode, so the two methods are being executed in two different services that are not linked with each other. I. would like to keep things that way, so if there are some

 


Tsvetan Georgiev
 

Hi Malik,

The contract API is used to invoke a chaincode usually deployed as separate instance (could be on the same or different channel).

When you need to call a method inside your chaincode you just call that method instead of using the invoke API.

If you need to have clear separation of the functionalities you better separate them and deploy as different chaincodes. That way you can use the contract API to call a chaincode from a chaincode.

I suggest to go through the following documentation (helps a lot to design properly your chaincodes): https://hyperledger-fabric.readthedocs.io/en/release-2.3/developapps/chaincodenamespace.html



Senofi

Tsvetan Georgiev
Director, Senofi Inc.

438-494-7854 | tsvetan@...

www.senofi.ca

www.consortia.io







---- On Tue, 30 Mar 2021 06:30:43 -0400 Marek Malik <info@...> wrote ----

Hello Guys, 

Just a quick question. 

I have this scenario where I'm calling one method inside a chaincode A (let's say to update some properties based on external factors). Now, these external factors are being returned by a second method inside the same chaincode. I'm trying to call this method using the contract api interface using the Stub (invokeChaincodeWithStringArgs). But I'm getting an error on the execution of that call. Is there any possibility to make such call or there is some limitation and I need to create a new chaincode for that second method?

I have encapsulation inside the chaincode, so the two methods are being executed in two different services that are not linked with each other. I. would like to keep things that way, so if there are some