You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过编程方式创建Hyperledger钱包?自定义路径需求

Creating a Custom Path Wallet in Hyperledger Composer

Absolutely! You don’t have to stick with the default wallet path—you can create a wallet pointing to any directory you choose using the FileSystemWallet class directly. Here’s how to do it, step by step:

Step 1: Import the required class

First, make sure you pull in the FileSystemWallet class from the Composer library:

const { FileSystemWallet } = require('composer-common');

Step 2: Initialize your custom path wallet

Instantiate the FileSystemWallet by passing your desired directory path as the argument. This can be any valid filesystem path your application has read/write access to—no need to follow the default ~/.composer/client-data/ structure:

// Replace this with your actual custom directory path
const customWalletDir = '/home/your-username/my-custom-wallet';
const wallet = new FileSystemWallet(customWalletDir);

If you want to use this custom wallet with an existing bizNetworkConnection instance, you can explicitly set it using the setWallet method:

this.bizNetworkConnection.setWallet(wallet);

// Now when you fetch the wallet, it will use your custom path
const adminWallet = await this.bizNetworkConnection.cardStore.getWallet('admin@proak-hyperledger-network');

Bonus: Import cards to your custom wallet

If you need to add existing identity cards to this new wallet, use the import method:

// Assuming you have a card object (e.g., loaded from a .card file)
await wallet.import('admin@proak-hyperledger-network', card);

This gives you full control over where your wallet data is stored, avoiding the default path you can’t use.

内容的提问来源于stack exchange,提问作者Marcus Ataide

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:26:00