Hyperledger Fabric as a data source in GeneXus

Unofficial Content
This documentation is valid for:

GeneXus adds the support of Hyperledger Fabric to facilitate cross-industry projects that require integration with an enterprise-grade blockchain.

That GeneXus adds Hyperledger to its supported Data Stores gives the developer the chance to create solutions that integrate to a blockchain as easily as to any other relational DBMS, Odata services and other data sources.

GeneXus generates the application with its services that connect to the middleware, and, to enforce business rules, also generates the smart contracts using chaincode.

image_2019108154129_1_png

 

First steps

1) Add HyperLedger as a Data Store

Go to Preferences > My Knowledge Base > My Version > My Environment > Data Stores > New Data Store > Service

Set properties

  • ServerName: <Server uri>
  • UserID: <Username>
  • User Password <Password>
  • Datastore Provider: HyperLedger
  • Chaincode Prefix: <Unique identifier of the entities in this Hyperledger installation>

2)  Create a Transaction

Customer
{
   CustomerId*
   CustomerName
}
#Rules
   error("Customer Name must not be empty") if CustomerName.IsEmpty();

 

3) Define a DataView

You can defined it 'by hand' or make GeneXus define it. 
Right-click on the 'Customer' Transaction > Link to Service Data View. This will create the following dataview:

Customer_DV
{
   CustomerId*
   CustomerName
}
#DataStores
   Service with Properties {Name= BlockChainTest_customer, Use Externalname = Yes}

Properties of Customer_DV:
Associated Table = Customer
Datastore = HyperLedger (Service)
Note: GeneXus provides an Hyperledger instance for concept proofing. Refer to section 'POC settings' for more information.

4) Add Build Options

 

Go to GeneXus Menu > Build > Build Events

Set in the Post-build event command line:

msbuild "{GenexusPath}\gxnet\gxbuildcc.msbuild" /property:GX_TARGET_PATH="{TargetFullPath}";GX_PROGRAM_DIR={GenexusPath}

POC settings

You may use these settings only for proof of concept purposes. Do not use it for any other purpose.
This instance is provided by http://powerledgers.com.

Server = "https://melisandre.ddns.net/api"
UserName= "gxuser"
UserPassword= "domingo.menchaca.4096.fuxia"
Chaincode prefix = "put here a string that represents your company name  + your name so that you can be contacted" 

Restrictions

Take into account that Blockchain is a key/value storage

  • It does not allow operations with Order clause
  • It allows filters and conditions on its primary key only