[英]How to add anchor peers on channel using node sdk hyperledger fabric
[英]How to fetch list of transactions using hyperledger fabric node sdk
我想使用節點sdk來獲取事務列表,但是我找不到任何參考,我使用的是結構的高級節點sdk。
以下是我用來連接網絡的代碼:
'use strict';
const { FileSystemWallet, Gateway } = require('fabric-network');
const fs = require('fs');
const path = require('path');
const ccpPath = path.resolve(__dirname, 'connection.json');
const ccpJSON = fs.readFileSync(ccpPath, 'utf8');
const ccp = JSON.parse(ccpJSON);
async function main() {
const identity = 'testuser';
try {
// Create a new file system based wallet for managing identities.
const walletPath = path.join(process.cwd(), 'wallet');
const wallet = new FileSystemWallet(walletPath);
console.log(`Wallet path: ${walletPath}`);
// Check to see if we've already enrolled the user.
const userExists = await wallet.exists(identity);
if (!userExists) {
console.log(`An identity for the user "${identity}" does not exist in the wallet`);
console.log('Run the registerUser.js application before retrying');
return;
}
// Create a new gateway for connecting to our peer node.
const gateway = new Gateway();
await gateway.connect(ccp, { wallet, identity: identity, discovery: { enabled: false } });
// Get the network (channel) our contract is deployed to.
const network = await gateway.getNetwork('mychannel');
} catch (error) {
console.error(`Error: ${error}`);
process.exit(1);
}
}
main();
我已連接到網絡,但沒有使用什么功能來獲取最近的交易和分頁。
任何幫助表示贊賞,謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.