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

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):


Tsvetan Georgiev
Director, Senofi Inc.

438-494-7854 | tsvetan@...

---- 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


Join to automatically receive all group messages.