Reputation: 771
I am using fabric 2.1, with new client library fabric-network. I have configured network, created channel, installed chaincode, etc. I could invoke transactions through CLI.
Fabric Version: 2.1 fabric-network:2.1
I have defined Event Handler Strategy as below 1) strategy: DefaultEventHandlerStrategies.MSPID_SCOPE_ANYFORTX
2) strategy: createTransactionEventHandler
await gateway.connect(ccp, {
wallet, identity: username, discovery: { enabled: true, asLocalhost: true }, transaction: {
strategy: DefaultEventHandlerStrategies.MSPID_SCOPE_ANYFORTX
}
});
When I submit the transaction, getting an empty buffer in both cases instead of transaction id(Not sure if we get tx id).
The invoked transaction is getting added to the blockchain. I confirmed it from CouchDB and querying the asset.
> let result = await contract.submitTransaction(fcn, args[0], args[1],args[2], args[3], args[4]);
I tried with a custom event handler, but this function is not getting triggered. strategy: createTransactionEventHandler
const createTransactionEventHandler = (transactionId, network) => { const mspId = network.getGateway().getIdentity().mspId; const myOrgPeers = network.getChannel().getEndorsers(mspId); console.log(`tx id : ${transactionId}`) return new MyTransactionEventHandler(transactionId, network, myOrgPeers); }
Does anyone have any suggestions?
Upvotes: 0
Views: 180
Reputation: 1
Check the chaincode, I had a similar issue where I was receiving an empty Buffer. If you are using fabcar, I assume you are calling this function:
async createCar(ctx, carNumber, make, model, color, owner) {
console.info('============= START : Create Car ===========');
const car = {
color,
docType: 'car',
make,
model,
owner,
};
await ctx.stub.putState(carNumber, Buffer.from(JSON.stringify(car)));
console.info('============= END : Create Car ===========');
return car; // if you don't return anything you get an empty response
}
So check if your chaincode is supposed to return anything in the first place.
Upvotes: 0