1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| const shim = require('fabric-shim'); const Chaincode = class{ async Init(stub){ var ret = stub.getFunctionAndParameters(); var args = ret.params; var a = args[0]; var aValue = args[1]; var b = args[2]; var bValue = args[3]; await stub.putState(a,Buffer.from(aValue)); await stub.putState(b,Buffer.from(bValue)); return shim.success(Buffer.from('heima chaincodinit successs')); } async Invoke(stub){ let ret = stub.getFunctionAndParameters(); let fcn = this[ret.fcn]; return fcn(stub,ret.params); } async query(stub,args){ let a = args[0]; let balance = await stub.getState(a); return shim.success(balance); }
}; shim.start(new Chaincode());
|