Search code examples
interfacehyperledger-fabrichyperledgerabichaincode

Hyperledger Fabric: How to keep chaincode-calling application and deployed chaincode in sync ? Any ABI equivalent feature?


There is no concept of ABI(Application Binary Interface) in Hyperledger fabric as it is there in Ethereum/Quorum.

An ABI file in Quorum is generated while compiling the Smart-contract(chaincode), which is further used by the client-application as the reference to the function definition of the deployed smart-contract.

For example: If there is a function named getAsset(assetId: string) which returns an Asset object, this complete information will be defined in the ABI file.

So, In short, ABI serves the purpose of an interface of a deployed smart-contract, and, also stays with the client-application as a reference of the function definitions of the deployed smart-contract, Which omits the possibility of the application being out of sync with the deployed contract and calling the smart-contract's functions with incorrect arguments.

Now, I am wondering how this problem can be solved in Hyperledger Fabric.

I was going through asset-transfer-basic (javascript application), there I can see a method named CreateAsset that accepts (assetId, color, owner, size, appraisedValue) but they are being passed explicitly.

What I mean by that is, there is no other way to know what arguments CreateAsset accepts without manually looking at the implementation of the function in the smart-contract.

Is there any way to solve this problem?


Solution

  • contract = network.getContract('mychaincode', 'org.hyperledger.fabric');
    result = await contract.evaluateTransaction('org.hyperledger.fabric:GetMetadata');
    metadata = JSON.parse(result.toString('utf8'));