Leveraging Stellar for settling transactions on Hyperledger fabric network — part 2

Sachin Jha
Coinmonks
Published in
2 min readSep 25, 2018

--

This part has technical details of changes made in Hyperledger Fabric smart contract and Stellar APIs used to settle a transaction and complete transfer in Fabric network. It is recommended that you take a look at part 1 of this series in order to get the complete background.

  1. Changes to marbles.go (asset definitions ) :
Fig 1. (marbles.go )

2. Methods added to write_ledger.go to build the workflow where seller can mark a marble for sale and buyers can create offers with offer price. Straight forward changes to golang smart contract given the structure above. The methods are:

a) mark_for_sale b) make_offer c) accept_offer .

The code changes can be found in this file.

3. Client side code to make payment :

Very little modification was required to the sample, given in Stellar API reference, for sending payments. Memo field includes the offerId.

Native currency has been used but one can easily change the currency to some anchored asset.

4. Vendoring stellar sdk and its dependencies in marbles chaincode

Stellar uses ‘dep for dependency management whereas fabric relies on ‘vendoring technique for managing external dependencies. Steps to, manage all dependencies and complete this task are documented in this README file.

5. Smart contract changes in write_ledger.go and lib.go to verify payment has been made for a given offer_id

Explanation of Stellar APIs being used to verify payment

a) getTransaction: /transactions/<id>:

Returns the details of a given Transaction. The memo field can be read from here to cross check the offerId against which the payment was made.

b)getPayments for GivenTransaction: /transactions/<id>/payments

Returns payment operations in a given transaction. Since transaction to make payment has only one operation, we can get the payment details from the first operation which will be of type payment.

To test this end to end some more changes will be required in the marbles client which is still pending.

Get Best Software Deals Directly In Your Inbox

--

--

Sachin Jha
Coinmonks

Cloud Solution Architect, Blockchain enthusiast and a passionate Badminton and Tennis player.