MCPcopy
hub / github.com/yeasy/blockchain_guide / putJSON

Function putJSON

11_app_dev/chaincode_example05.go:303–312  ·  view source on GitHub ↗
(ctx contractapi.TransactionContextInterface, key string, value interface{})

Source from the content-addressed store, hash-verified

301}
302
303func putJSON(ctx contractapi.TransactionContextInterface, key string, value interface{}) error {
304 data, err := json.Marshal(value)
305 if err != nil {
306 return fmt.Errorf("failed to encode %s: %w", key, err)
307 }
308 if err := ctx.GetStub().PutState(key, data); err != nil {
309 return fmt.Errorf("failed to write %s: %w", key, err)
310 }
311 return nil
312}
313
314func homeKey(address string) string {
315 return "home:" + address

Callers 2

BuyByAddressMethod · 0.70
putHomeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected