Search code examples
mongodbhyperledger-fabrichyperledgerwallet

How to create Database wallet into hyperledger-fabric?


I need to use a database (mysql/mongodb) instead of files to store the user's wallet identity into hyperledger-fabric.


Solution

  • The Fabric client SDKs only provide file-system and CouchDB wallet storage out-of-the-box so you have two options:

    1. Write your own WalletStore implementation that stores and retrieves data from MongoDB.
    2. Store the client credentials however you want (in your database of choice or any other location), and then pass them to the SDK directly as an X509Identity object in the identity field of the connection options.

    See this tutorial and the WalletStore documentation for details of how to use a custom WalletStore implementation. You might also refer to the CouchDB store implementation as a reference.

    Note that for Hyperledger Fabric v2.4 and later, the Fabric Gateway client API is the preferred API for Node, Java and Go applications. The model used with this API is for you to store client credentials however you chose (which could still be in a wallet) and then just supply an identity and signing implementation using those credentials to the API on connection. See the migration guide for details.