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

Method IssueCoin

11_app_dev/chaincode_example03.go:93–109  ·  view source on GitHub ↗

IssueCoin increases the central-bank supply.

(ctx contractapi.TransactionContextInterface, amount string)

Source from the content-addressed store, hash-verified

91
92// IssueCoin increases the central-bank supply.
93func (s *SmartContract) IssueCoin(ctx contractapi.TransactionContextInterface, amount string) (*Transaction, error) {
94 value, err := parsePositiveAmount(amount)
95 if err != nil {
96 return nil, err
97 }
98
99 centerBank, err := readCenterBank(ctx)
100 if err != nil {
101 return nil, err
102 }
103 centerBank.TotalNumber += value
104 centerBank.RestNumber += value
105 if err := putJSON(ctx, centerBankKey, centerBank); err != nil {
106 return nil, err
107 }
108 return recordTransaction(ctx, 0, 0, 0, 0, value)
109}
110
111// IssueCoinToBank transfers issued currency from the central bank to a commercial bank.
112func (s *SmartContract) IssueCoinToBank(ctx contractapi.TransactionContextInterface, bankID string, amount string) (*Transaction, error) {

Callers

nothing calls this directly

Calls 4

readCenterBankFunction · 0.85
recordTransactionFunction · 0.85
parsePositiveAmountFunction · 0.70
putJSONFunction · 0.70

Tested by

no test coverage detected