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

Function putJSON

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

Source from the content-addressed store, hash-verified

400}
401
402func putJSON(ctx contractapi.TransactionContextInterface, key string, value interface{}) error {
403 data, err := json.Marshal(value)
404 if err != nil {
405 return fmt.Errorf("failed to encode %s: %w", key, err)
406 }
407 if err := ctx.GetStub().PutState(key, data); err != nil {
408 return fmt.Errorf("failed to write %s: %w", key, err)
409 }
410 return nil
411}
412
413func bankKey(id int) string {
414 return fmt.Sprintf("bank:%d", id)

Callers 8

InitLedgerMethod · 0.70
CreateBankMethod · 0.70
CreateCompanyMethod · 0.70
IssueCoinMethod · 0.70
IssueCoinToBankMethod · 0.70
IssueCoinToCompanyMethod · 0.70
TransferMethod · 0.70
recordTransactionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected