The contract state
Each contract has access to a sandboxed state for storage of data. The write actions on the state are rolled back in case the contract operation returns an error. If a transaction is successfully commited, it contains the hash of the state root so that any given state is commited to the blockchain.
Writing to the state
Set operation on the contract context to save to the state.
Set(key byte, pb proto.Message) error
go-loom mandates that the data being saved is a protobuf object.
Reading from the state
Has operation to check whether a particular key exists in
Has(key byte) bool
To read the value saved at a key use the
Get(key byte, pb proto.Message) error
Get will unmarshal the saved data into a protobuf struct
Deleting a key
Data saved at a key can be delete with