Writing Chaincode Hyperledger Fabric

  1. setUser
  • Arguments will be passed to the setUser function.
  • Convert the second argument age from string to integer.
  • Create object of the structure User
  • Convert the user object to the Bytes using json.Marshal function.
  • Use stub.PutState function to store the user in the legder using username as the key.
  • Use stub.GetState function to get user from the legder. Pass UserName as key .
  • User data will in the bytes and return it.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store