ChaincodeStub is implemented by the fabric-shim library. It is supplied to ChaincodeInterface and encapsulates the APIs between the chaincode implementation and the Fabric peer.
Although stub has many functions, this section lists a few of them that are frequently used:
- getFunctionAndParameters() (string, []string): This method helps to get the function and the parameters from the stub. This method returns two values: the name of the function as a string and the parameters as a string array.
- getState(key string) ([]byte, error): This method fetches data from the state ledger by the given key. It doesn't read data from the ledger that has not been committed. It returns data as a byte array and error information if there ...