Question about Function basic

Hey guys I’m learning about Hyperledger Fabric and I have never learned about Go lang.
So I’m not used to this lang. And I saw code like this

func (s *SmartContract) Invoke(APIstub shim.ChaincodeStubInterface) sc.Response {

this is the tutorial code for the Hyperledger Fabric. I’m curious about the (s *SmartaContract). I heard that the function name is Invoke and it gets parameter named APIstub(shim.ChaincodeStubInterface type). And the function returns sc.Response type thing.
As I said above I wanna know what the (s *SmartContract) means.

Why are you editing your post away?

I think it would be much better if you had left the question and answered it by yourself. Then other people the same or a similar question might find it via google.

(s *SmartContract) is the method receiver. This means that to call the above Invoke() function you will need to do it via instanceOfSmartContract.Invoke(......). It is a pointer receiver, so Invoke() can modify the underlying SmartContract ("s").

You can take a look at a few of the slides from this point for an explanation of receivers and pointer vs value receivers:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.