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

Method CreateCompany

11_app_dev/chaincode_example03.go:80–90  ·  view source on GitHub ↗

CreateCompany registers a company.

(ctx contractapi.TransactionContextInterface, name string)

Source from the content-addressed store, hash-verified

78
79// CreateCompany registers a company.
80func (s *SmartContract) CreateCompany(ctx contractapi.TransactionContextInterface, name string) (*Company, error) {
81 id, err := nextID(ctx, companyCounterKey)
82 if err != nil {
83 return nil, err
84 }
85 company := &Company{ID: id, Name: name}
86 if err := putJSON(ctx, companyKey(id), company); err != nil {
87 return nil, err
88 }
89 return company, nil
90}
91
92// IssueCoin increases the central-bank supply.
93func (s *SmartContract) IssueCoin(ctx contractapi.TransactionContextInterface, amount string) (*Transaction, error) {

Callers

nothing calls this directly

Calls 3

companyKeyFunction · 0.85
nextIDFunction · 0.70
putJSONFunction · 0.70

Tested by

no test coverage detected