首页 > 解决方案 > 如何将钱包凭证放入composer-wallet-inmemory?

问题描述

如何将钱包凭证composer-wallet-inmemory放入 v.0.19.5?

这是方法:

/**
     * Add a new credential to the wallet.
     *
     * @param {string} name The name of the credentials.
     * @param {string} value The credentials.
     * @return {Promise} A promise that is resolved when
     * complete, or rejected with an error.
     */
    put(name, value) {

        if (!name) {
            return Promise.reject(new Error('Name must be specified'));
        }

        if (value instanceof IdCard || value instanceof Buffer || value instanceof String  || typeof value === 'string'){
            this.store.set( this._path(name),value);
            return Promise.resolve();
        }else {
            return Promise.reject(new Error('Unkown type being stored'));
        }


    }

标签: hyperledger-fabrichyperledgerhyperledger-composer

解决方案


您不应该尝试直接与 composer-wallet 实现进行交互。您应该使用 AdminConnection 的实例来管理卡片商店中的卡片

https://hyperledger.github.io/composer/latest/api/admin-adminconnection

并配置您的环境以使用内存钱包,如此处所述

https://hyperledger.github.io/composer/latest/business-network/cloud-wallets


推荐阅读