如何使用hyperledger结构节点sdk获取事务列表

问题描述 投票:1回答:1

我想使用节点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();

我已连接到网络,但没有用于获取最近的事务和分页的功能。

任何帮助表示赞赏,谢谢。

node.js transactions sdk fetch hyperledger-fabric
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.