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

Method CreateBank

11_app_dev/chaincode_example03.go:67–77  ·  view source on GitHub ↗

CreateBank registers a commercial bank.

(ctx contractapi.TransactionContextInterface, name string)

Source from the content-addressed store, hash-verified

65
66// CreateBank registers a commercial bank.
67func (s *SmartContract) CreateBank(ctx contractapi.TransactionContextInterface, name string) (*Bank, error) {
68 id, err := nextID(ctx, bankCounterKey)
69 if err != nil {
70 return nil, err
71 }
72 bank := &Bank{ID: id, Name: name}
73 if err := putJSON(ctx, bankKey(id), bank); err != nil {
74 return nil, err
75 }
76 return bank, nil
77}
78
79// CreateCompany registers a company.
80func (s *SmartContract) CreateCompany(ctx contractapi.TransactionContextInterface, name string) (*Company, error) {

Callers

nothing calls this directly

Calls 3

bankKeyFunction · 0.85
nextIDFunction · 0.70
putJSONFunction · 0.70

Tested by

no test coverage detected