Chaincode interface is mandatory to implement chaincode that has two methods:
- Init(): This method will be invoked only once in the life of the chaincode, when the chaincode is instantiated or upgraded. This method helps to set up the initial state of the ledger, such as initializing any serial numbers. It expects the ChaincodeStubInterface object as input and returns the peer.Response object.
Syntax: Init(stub ChaincodeStubInterface)
- Invoke(): This method will help to invoke the user transaction. You may have several operations in your code, but when a client sends a request to chaincode, it only comes to the Invoke() method and, from here, this method will dispatch to the corresponding transaction. This method also ...