All Projects → khanhnb → Balance Transfer Go

khanhnb / Balance Transfer Go

Licence: apache-2.0
A sample go app to demonstrate fabric-client & fabric-ca-client go SDK APIs

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Balance Transfer Go

Pivt
Helm charts for running and operating Hyperledger Fabric in Kubernetes. Previously hosted at https://github.com/APGGroeiFabriek/PIVT.
Stars: ✭ 159 (+736.84%)
Mutual labels:  blockchain, hyperledger-fabric
Fabric Multi Network
Stars: ✭ 16 (-15.79%)
Mutual labels:  blockchain, hyperledger-fabric
Study Blockchain Referrence
区块链学习路上的一些资料作为参考
Stars: ✭ 172 (+805.26%)
Mutual labels:  blockchain, hyperledger-fabric
Todo List Fabricv1
A todo list application using Hyperledger Fabric V1 as a data source
Stars: ✭ 103 (+442.11%)
Mutual labels:  blockchain, hyperledger-fabric
Blockchain Network On Kubernetes
Demonstrates the steps involved in setting up your business network on Hyperledger Fabric using Kubernetes APIs on IBM Cloud Kubernetes Service.
Stars: ✭ 261 (+1273.68%)
Mutual labels:  blockchain, hyperledger-fabric
Decentralized Energy Composer
WARNING: This repository is no longer maintained ⚠️ We are no longer showing the Hyperledger Composer Service.
Stars: ✭ 129 (+578.95%)
Mutual labels:  blockchain, hyperledger-fabric
Evote
A voting application that leverages Hyperledger Fabric and the IBM Blockchain Platform to record and tally ballots.
Stars: ✭ 208 (+994.74%)
Mutual labels:  blockchain, hyperledger-fabric
Loyalty Points Evm Fabric
Sample use of Ethereum smart contract in Hyperledger Fabric
Stars: ✭ 35 (+84.21%)
Mutual labels:  blockchain, hyperledger-fabric
Heroes Service
Short tutorial to build a blockchain application in Go with Hyperledger Fabric
Stars: ✭ 248 (+1205.26%)
Mutual labels:  blockchain, hyperledger-fabric
Blockchain Application Using Fabric Java Sdk
Create and Deploy a Blockchain Network using Hyperledger Fabric SDK Java
Stars: ✭ 237 (+1147.37%)
Mutual labels:  blockchain, hyperledger-fabric
Blockchainbean2
This code pattern shows how to model a supply-chain network using the IBM Blockchain Platform and is based on a collaboration with Brooklyn Roasting Company. The story, along with the supply-chain documents that were used to model this network, can be found at: https://www.ibm.com/blockchainbean. Note that the 'view the blockchain' button is being migrated''
Stars: ✭ 90 (+373.68%)
Mutual labels:  blockchain, hyperledger-fabric
Build Blockchain Insurance App
Sample insurance application using Hyperledger Fabric
Stars: ✭ 609 (+3105.26%)
Mutual labels:  blockchain, hyperledger-fabric
Blockchain Real Estate
🚀基于区块链的房地产交易系统小模型。提供销售和捐赠功能。本项目使用Hyperledger Fabric构建区块链网络, go编写智能合约,应用层使用gin+fabric-sdk-go调用合约。前端展示使用vue+element。体验地址:http://blockchain.togettoyou.com/web
Stars: ✭ 81 (+326.32%)
Mutual labels:  blockchain, hyperledger-fabric
Blockchainbooks.github.io
Blockchain Books
Stars: ✭ 139 (+631.58%)
Mutual labels:  blockchain, hyperledger-fabric
Blockchain Learning
Learn and promote blockchain together by writing
Stars: ✭ 44 (+131.58%)
Mutual labels:  blockchain, hyperledger-fabric
Fabric Starter
Starter Application and Deployment Scripts for Hyperledger Fabric
Stars: ✭ 202 (+963.16%)
Mutual labels:  blockchain, hyperledger-fabric
Bigchaindb Hyperledger
BigchainDB integration with HyperLedger Fabric. In collaboration with TheLedger
Stars: ✭ 20 (+5.26%)
Mutual labels:  blockchain, hyperledger-fabric
Decentralized Energy Fabric On Ibp20
Set up a network on the IBM Blockchain Platform and deploy a decentralized energy smart contract on the network.
Stars: ✭ 29 (+52.63%)
Mutual labels:  blockchain, hyperledger-fabric
Blockchainnetwork Compositejourney
Part 1 in a series of patterns showing the building blocks of a Blockchain application
Stars: ✭ 217 (+1042.11%)
Mutual labels:  blockchain, hyperledger-fabric
Zerotoblockchain
Tutorial for Zero to Blockchain series
Stars: ✭ 272 (+1331.58%)
Mutual labels:  blockchain, hyperledger-fabric

Balance transfer go

A sample go app to demonstrate fabric-client & fabric-ca-client go SDK APIs

Prerequisites and setup:

cd $GOPATH/src/github.com
git clone https://github.com/khanhnb/balance-transfer-go.git
sudo -- sh -c 'echo "127.0.0.1 ca.org1.example.com ca.org2.example.com orderer.example.com peer0.org1.example.com peer1.org1.example.com peer0.org2.example.com peer1.org2.example.com" >> /etc/hosts'

Once you have completed the above setup, you will have provisioned a local network with the following docker container configuration:

  • 2 CAs
  • A SOLO orderer
  • 4 peers (2 peers per Org)

Artifacts

  • Crypto material has been generated using the cryptogen tool from Hyperledger Fabric and mounted to all peers, the orderering node and CA containers. More details regarding the cryptogen tool are available here.
  • An Orderer genesis block (genesis.block) and channel configuration transaction (mychannel.tx) has been pre generated using the configtxgen tool from Hyperledger Fabric and placed within the artifacts folder. More details regarding the configtxgen tool are available here.

Running the sample program

Terminal Window 1
  • Launch the network using docker-compose
cd $GOPATH/src/github.com/balance-transfer-go
docker-compose -f artifacts/docker-compose.yaml up -d
# view logs of setup container
docker logs -f cli
Terminal Window 2
  • Run go REST Service
go run main.go
Terminal Window 3

Sample REST APIs Requests

Login Request

  • Register and enroll new users in Organization - Org1:
curl -s -X POST http://localhost:4000/users -H "content-type: application/x-www-form-urlencoded" -d 'username=Jim&orgName=org1&secret=123'

OUTPUT:

{
  "Success": true,
  "Message": "Jim enrolled Successfully",
  "Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0OTQ4NjU1OTEsInVzZXJuYW1lIjoiSmltIiwib3JnTmFtZSI6Im9yZzEiLCJpYXQiOjE0OTQ4NjE5OTF9.yWaJhFDuTvMQRaZIqg20Is5t-JJ_1BP58yrNLOKxtNI"
}

The response contains the success/failure status, an enrollment Secret and a JSON Web Token (JWT) that is a required string in the Request Headers for subsequent requests.

Invoke request

curl -s -X POST \
  http://localhost:4000/channels/mychannel/chaincodes/mycc \
  -H "authorization: <put JSON Web Token here>" \
  -H "content-type: application/json" \
  -d '{
	"peers": ["peer0.org2.example.com","peer1.org2.example.com"],
	"fcn":"invoke",
	"args":["a","b","10"]
}'

NOTE: Ensure that you save the Transaction ID from the response in order to pass this string in the subsequent query transactions.

Chaincode Query

curl -s -X GET \
  "http://localhost:4000/channels/mychannel/chaincodes/mycc?peer=peer0.org1.example.com&fcn=query&args=%5B%22a%22%5D" \
  -H "authorization: <put JSON Web Token here>" \
  -H "content-type: application/json"

Query Block by BlockNumber

curl -s -X GET \
  "http://localhost:4000/channels/mychannel/blocks/1?peer=peer0.org1.example.com" \
  -H "authorization: <put JSON Web Token here>" \
  -H "content-type: application/json"

Query Transaction by TransactionID

curl -s -X GET http://localhost:4000/channels/mychannel/transactions/<put transaction id here>?peer=peer0.org1.example.com \
  -H "authorization: <put JSON Web Token here>" \
  -H "content-type: application/json"

NOTE: The transaction id can be from any previous invoke transaction, see results of the invoke request, will look something like 8a95b1794cb17e7772164c3f1292f8410fcfdc1943955a35c9764a21fcd1d1b3.

Query ChainInfo

curl -s -X GET \
  "http://localhost:4000/channels/mychannel?peer=peer0.org1.example.com" \
  -H "authorization: <put JSON Web Token here>" \
  -H "content-type: application/json"

Query Installed chaincodes

curl -s -X GET \
  "http://localhost:4000/chaincodes?peer=peer0.org1.example.com" \
  -H "authorization: <put JSON Web Token here>" \
  -H "content-type: application/json"

Query Instantiated chaincodes

curl -s -X GET \
  "http://localhost:4000/channels/{channelName}/chaincodes?peer=peer0.org1.example.com" \
  -H "authorization: <put JSON Web Token here>" \
  -H "content-type: application/json"

Query Channels

curl -s -X GET \
  "http://localhost:4000/channels?peer=peer0.org1.example.com" \
  -H "authorization: <put JSON Web Token here>" \
  -H "content-type: application/json"

Reference

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].