Search code examples
hyperledger-fabrichyperledgerhyperledger-composer

Create Hyperledger Wallet Programmatically


With the following command:

const wallet = await this.bizNetworkConnection.cardStore.getWallet('admin@proak-hyperledger-network');

I can get the wallet from the default path: '˜/.composer/client-data/admin@proak-hyperledger-network'

However I cant use the default path, so I'd like create the wallet. There is a method to something like?

let wallet = new Wallet(args)

Solution

  • I found a way to specify the wallet path. You need to pass some options to BusinessNetworkConnection.

    constructor() {
        let connectionOptions = {}
        connectionOptions = {
            wallet : {
              type: 'composer-wallet-filesystem',
              options : {
                storePath : '/tmp/.composer'
              }
            }
          };
        this.bizNetworkConnection = new BusinessNetworkConnection(connectionOptions);
      }