How to use the fabric-shim.start function in fabric-shim

To help you get started, we’ve selected a few fabric-shim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / fabric-test / chaincodes / marbles / node / marbles_chaincode.js View on Github external
if (args.length < 1) {
      throw new Error('Incorrect number of arguments. Expecting 1')
    }
    let marbleName = args[0];
    console.info('- start getHistoryForMarble: %s\n', marbleName);

    let resultsIterator = await stub.getHistoryForKey(marbleName);
    let method = thisClass['getAllResults'];
    let results = await method(resultsIterator, true);

    return Buffer.from(JSON.stringify(results));
  }
};

shim.start(new Chaincode());
github hyperledger / fabric-sdk-node / test / scenario / chaincode / marbles0 / node / marbles.js View on Github external
async getHistoryForMarble(stub, args, thisObject) {

		if (args.length !== 1) {
			return shim.error('Incorrect number of arguments. Expecting 1');
		}
		const marbleName = args[0];
		console.info('- start getHistoryForMarble: %s\n', marbleName);

		const resultsIterator = await stub.getHistoryForKey(marbleName);
		const results = await thisObject.getAllResults(resultsIterator, true);

		return shim.success(Buffer.from(JSON.stringify(results)));
	}
};

shim.start(new Chaincode());
github hyperledger / fabric-sdk-node / test / fixtures / chaincode / node_cc / example_cc1 / chaincode.js View on Github external
}

		return shim.success(v);
	}

	/*
	* Used to return what's in the input for testing purposes
	* */
	async echo(stub, args) {
		logger.info('Echo Response\n');

		return shim.success(Buffer.from(args[0]));
	}
};

shim.start(new Chaincode());
github hyperledger / fabric-sdk-node / test / fixtures / chaincode / node_cc / example_cc / chaincode.js View on Github external
});
		const payload = Buffer.from(JSON.stringify(result));
		return shim.success(payload);
	}

	async echo(stub, args) {
		stub.setEvent('echo', Buffer.from('content'));
		if (args.length > 0) {
			return shim.success(Buffer.from(args[0]));
		} else {
			return shim.success();
		}
	}
};

shim.start(new Chaincode());
github Kunstmaan / hyperledger-fabric-chaincode-dev-setup / example-chaincode / fabcar1 / chaincode.js View on Github external
};

function setEvent(stub, name, payload) {
    let bufferedPayload;

    if (Buffer.isBuffer(payload)) {
        bufferedPayload = payload;
    } else {
        bufferedPayload = Buffer.from(JSON.stringify(payload));
    }

    console.log(`Event ${name} created for ${JSON.stringify(payload)}`);
    return stub.setEvent(name, bufferedPayload);
}

shim.start(new Chaincode());
github IBM / car-auction-network-fabric-node-sdk / chaincode / carauction.js View on Github external
await stub.putState(listingKey, Buffer.from(JSON.stringify(listing)));        
      }
    }
    console.info('inspecting vehicle: ');
    console.info(util.inspect(vehicle, { showHidden: false, depth: null }));

    if (highestOffer) {
      //update the owner of the vehicle
      await stub.putState(listing.vehicle, Buffer.from(JSON.stringify(vehicle)));
    } else { throw new Error('offers do not exist: '); }

    console.info('============= END : closeBidding ===========');
  }
};

shim.start(new Chaincode()); 
github IBM / car-auction-network-fabric-node-sdk / chaincode / fabcar.js View on Github external
await stub.putState(oldOwner, Buffer.from(JSON.stringify(seller))); 
      }
    }
    console.info('inspecting vehicle: ');                                            
    console.info(util.inspect(vehicle, {showHidden: false, depth: null}));

    if (highestOffer) {
      await stub.putState(listing.vehicle, Buffer.from(JSON.stringify(vehicle))); 
      //update the buyers balance
    } else { throw new Error('offers do not exist: '); }

    console.info('============= END : closeBidding ===========');
  }
};

shim.start(new Chaincode()); 
github Kunstmaan / hyperledger-fabric-chaincode-dev-setup / src / templates / createChaincode / chaincode / chaincode.js View on Github external
const shim = require('fabric-shim');
const {ChaincodeBase, ChaincodeError} = require('@kunstmaan/hyperledger-fabric-node-chaincode-utils');

const ERRORS = require('./common/constants/errors');
const CONSTANTS = require('./common/constants/index');

const YOUR_CHAINCODE_NAME_PASCAL_CASEDChaincode = class extends ChaincodeBase {
    constructor() {
        super(shim);
    }
};

shim.start(new YOUR_CHAINCODE_NAME_PASCAL_CASEDChaincode());
github Kunstmaan / hyperledger-fabric-kuma-token-example / chaincode / src / chaincodes / multisig / chaincode.js View on Github external
multisigTransferRequest.transaction.toAddress,
                    contract.walletAddress
                ]
            );

            multisigTransferRequest.executed = true;
        }

        await txHelper.putState(multisigTransferRequest.id, multisigTransferRequest);

        return multisigTransferRequest;
    }

};

shim.start(new MultisigChaincode(shim));
github Kunstmaan / hyperledger-fabric-kuma-token-example / chaincode / src / chaincodes / kuma-token / chaincode.js View on Github external
'details': error.details
            });
        }


        return new ContractWallet({
            chaincodeName,
            chaincodeFunctions,
            address: txHelper.uuid(CONSTANTS.PREFIXES.WALLET),
            amount: 0
        }).save(txHelper);
    }

};

shim.start(new KumaTokenChaincode(shim));