Reputation: 313
I have already run my hyperledger fabric network. So I have already registered, enrolled and put into couchdb wallet my users. Now I try to evaluate transaction 'ClientAccountBalance'. My node.js app:
let configPATH = 'path/to/config.yaml';
async function networkConnectorForUser(email) {
let wallet = await Wallets.newCouchDBWallet("http://XXXXX@XXXXX:5984");
let user = await wallet.get(email);
// connection profile
let connectionProfile = yaml.safeLoad(readFileSync(configPATH, 'utf-8'));
// create new gateway
let gateway = new Gateway();
await gateway.connect(connectionProfile, {
wallet,
identity: user
});
// get the network (channel) our contract is deployed to
let network = await gateway.getNetwork('mychannel');
return network;
}
async function transferTx(senderEmail, recipientEmail) {
let networkForSender = await networkConnectorForUser(senderEmail);
let networkForRecipient = await networkConnectorForUser(recipientEmail);
// get recipient id
let contractForRecipient = networkForRecipient.getContract('token-erc-20');
let recipientID = await contractForRecipient.evaluateTransaction('ClientAccountID');
console.log(`recipientID for ${recipientEmail}: `, recipientID.toString('ascii'));
// get total supply sender before transfer
let contractForSender = networkForSender.getContract('token-erc-20');
let totalSupplySender = await contractForSender.evaluateTransaction('TotalSupply');
console.log(`totalSupply for sender ${senderEmail} before transfer: `, totalSupplySender.toString('ascii'));
// get total supply recipient before transfer
let totalSupplyRecipient = await contractForRecipient.evaluateTransaction('TotalSupply');
console.log(`totalSupply for recipient ${recipientEmail} before transfer: `, totalSupplyRecipient.toString('ascii'));
let recipientBalance = await contractForRecipient.evaluateTransaction('ClientAccountBalance');
console.log('tokenName: ', tokenName.toString('ascii'));
}
transferTx('address.ru', 'address2.ru');
I receive next output:
recipientID for address2.ru: XXXXXXX
totalSupply for sender address.ru before transfer: 1000
totalSupply for recipient address2.ru before transfer: 1000
path/to/node_modules/fabric-network/lib/impl/query/singlequeryhandler.js:60
const responseError = Object.assign(new Error('peer error response: ' + result.message), result);
^
Error: the account XXXXXXX does not exist
at SingleQueryHandler.evaluate (/path/to/node_modules/fabric-network/lib/impl/query/singlequeryhandler.js:60:57)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Transaction.evaluate (/path/to/node_modules/fabric-network/lib/transaction.js:319:25)
at async transferTx (/path/to/test-fabric-example/transfer.js:489:21) {
isEndorsed: false,
payload: Buffer(0) [Uint8Array] [],
status: 500
}
Upvotes: 0
Views: 3064