Samples for Hyperledger Fabric
Find a file
Arun S M 7ee1bf793d
TLS enabled external chaincode example (#438)
* Enable TLS on asset-transfer-basic external chaincode

1. Introduce environment variables to enable or disable TLS
at runtime. Also, introduce environment variables which carries
the server key, cert and the client machine's root CA cert
information.
2. Read the environment variables to decide with appropriate
assumptions on default values to work as is today.

Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>

* Update the chaincode.env with new options

1. Introduce four new environment variables to the default
chaincode environment file.
2. Add two new environment files for easy/automation running
of the external chaincodes for different organizations.

Note that when TLS enabled, the package contents will change.
So each organization will have their own package ID
generated unlike earlier. Also, there will be two chaincode
containers running instead of one for the given example.

Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>

* Add docker compose file for running chaincodes

The file will build and run the chaincode on the fly.
Also, it will make use of the available files which is
configured by the user as part of execution. This will
help in bringup/bringdown of the chaincode containers.

In addition, it will help in updating the environment
variables on the go.

Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>

* Introduce crypto directory and ignore the pem contents

The directory is used by the docker-compose file for
automation. Instructions in the README.md file will
suffice the filling up of required files in this directory.

Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>

* Instructions on TLS enabled external chaincode server

1. Add instructions to generate a chaincode server TLS
parameters.
2. Add instructions on different parameters that peer node
expects and the chaincode expects.
3. Add instructions on steps to be followed in asset-transfer
-basic to work with iTLS enabled exteral chaincode.

Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>

* Enable chaincode to work without TLS as well

1. Root certificate is an optional parameter supplied for
chaincode to verify the peer's connection in response.
2. If TLS is enabled, then specify the key and cert
parameters. Do not expect it otherwise.

Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>
2021-04-20 11:06:46 +02:00
.github FAB-17777 Create basic settings.yaml (#165) 2020-04-22 08:09:56 +02:00
asset-transfer-abac Update Go Modules 2021-02-11 18:11:17 -05:00
asset-transfer-basic TLS enabled external chaincode example (#438) 2021-04-20 11:06:46 +02:00
asset-transfer-events Java chaincode samples fixed (#432) 2021-03-24 12:43:54 +00:00
asset-transfer-ledger-queries Update Go Modules 2021-02-11 18:11:17 -05:00
asset-transfer-private-data Java chaincode samples fixed (#432) 2021-03-24 12:43:54 +00:00
asset-transfer-sbe Java chaincode samples fixed (#432) 2021-03-24 12:43:54 +00:00
asset-transfer-secured-agreement Update Go Modules 2021-02-11 18:11:17 -05:00
auction Additional Auction Cleanup 2021-02-11 18:11:17 -05:00
chaincode abstore smart contract - Fixed Aval and Bval validation (#436) 2021-03-31 12:50:59 -04:00
ci Update "master" branch references to "main" 2021-03-19 19:23:09 -04:00
commercial-paper Fixed information leak 2021-04-19 11:50:02 -07:00
fabcar Update RegisterUser.java (#428) 2021-03-21 07:29:30 +01:00
high-throughput Update Go Modules 2021-02-11 18:11:17 -05:00
interest_rate_swaps Remove Stray IMAGE_TAG 2021-02-11 18:39:26 -05:00
off_chain_data Update "master" branch references to "main" 2021-03-19 19:23:09 -04:00
scripts Add CHANGELOG.md with script to update it (#162) 2020-05-19 15:52:13 +01:00
test-application/javascript Add SBE javascript application 2020-09-10 11:26:21 -04:00
test-network Change docker compose file version (#421) 2021-02-14 18:48:35 -05:00
token-erc-20 Stop ERC-20 transfer bug when to/from accounts are the same (#425) 2021-02-24 15:07:06 -05:00
token-erc-721 Add ERC721 non-fungible token sample for javascript Chaincode (#406) 2021-02-24 13:51:24 +00:00
token-utxo Update Go Modules 2021-02-11 18:11:17 -05:00
.gitignore Update Javascript and Typescript Deps (#403) 2021-01-13 12:19:31 -05:00
CHANGELOG.md Add CHANGELOG.md with script to update it (#162) 2020-05-19 15:52:13 +01:00
CODE_OF_CONDUCT.md FAB-9362 add CONTRIBUTING.md and CODE_OF_CONDUCT.md 2018-04-04 19:25:55 -04:00
CODEOWNERS Perform General Cleanup (#151) 2020-04-06 21:49:14 +02:00
CONTRIBUTING.md Fix doc link 2019-01-24 16:47:03 +08:00
LICENSE FAB-4853 initial content 2017-06-21 07:30:04 +08:00
MAINTAINERS.md Update "master" branch references to "main" 2021-03-19 19:23:09 -04:00
README.md Update "master" branch references to "main" 2021-03-19 19:23:09 -04:00
SECURITY.md [IN-68] Add default GitHub SECURITY policy 2019-09-25 10:22:26 -07:00

Hyperledger Fabric Samples

You can use Fabric samples to get started working with Hyperledger Fabric, explore important Fabric features, and learn how to build applications that can interact with blockchain networks using the Fabric SDKs. To learn more about Hyperledger Fabric, visit the Fabric documentation.

Getting started with the Fabric samples

To use the Fabric samples, you need to download the Fabric Docker images and the Fabric CLI tools. First, make sure that you have installed all of the Fabric prerequisites. You can then follow the instructions to Install the Fabric Samples, Binaries, and Docker Images in the Fabric documentation. In addition to downloading the Fabric images and tool binaries, the Fabric samples will also be cloned to your local machine.

Test network

The Fabric test network in the samples repository provides a Docker Compose based test network with two Organization peers and an ordering service node. You can use it on your local machine to run the samples listed below. You can also use it to deploy and test your own Fabric chaincodes and applications. To get started, see the test network tutorial.

Asset transfer samples and tutorials

The asset transfer series provides a series of sample smart contracts and applications to demonstrate how to store and transfer assets using Hyperledger Fabric. Each sample and associated tutorial in the series demonstrates a different core capability in Hyperledger Fabric. The Basic sample provides an introduction on how to write smart contracts and how to interact with a Fabric network using the Fabric SDKs. The Ledger queries, Private data, and State-based endorsement samples demonstrate these additional capabilities. Finally, the Secured agreement sample demonstrates how to bring all the capabilities together to securely transfer an asset in a more realistic transfer scenario.

Smart Contract Description Tutorial Smart contract languages Application languages
Basic The Basic sample smart contract that allows you to create and transfer an asset by putting data on the ledger and retrieving it. This sample is recommended for new Fabric users. Writing your first application Go, JavaScript, TypeScript, Java Go, JavaScript, TypeScript, Java
Ledger queries The ledger queries sample demonstrates range queries and transaction updates using range queries (applicable for both LevelDB and CouchDB state databases), and how to deploy an index with your chaincode to support JSON queries (applicable for CouchDB state database only). Using CouchDB Go, JavaScript Java, JavaScript
Private data This sample demonstrates the use of private data collections, how to manage private data collections with the chaincode lifecycle, and how the private data hash can be used to verify private data on the ledger. It also demonstrates how to control asset updates and transfers using client-based ownership and access control. Using Private Data Go, Java JavaScript
State-Based Endorsement This sample demonstrates how to override the chaincode-level endorsement policy to set endorsement policies at the key-level (data/asset level). Using State-based endorsement Java, TypeScript JavaScript
Secured agreement Smart contract that uses implicit private data collections, state-based endorsement, and organization-based ownership and access control to keep data private and securely transfer an asset with the consent of both the current owner and buyer. Secured asset transfer Go JavaScript
Events The events sample demonstrates how smart contracts can emit events that are read by the applications interacting with the network. README JavaScript, Java JavaScript
Attribute-based access control Demonstrates the use of attribute and identity based access control using a simple asset transfer scenario README Go None

Additional samples

Additional samples demonstrate various Fabric use cases and application patterns.

Sample Description Documentation
Commercial paper Explore a use case and detailed application development tutorial in which two organizations use a blockchain network to trade commercial paper. Commercial paper tutorial
Off chain data Learn how to use the Peer channel-based event services to build an off-chain database for reporting and analytics. Peer channel-based event services
Token ERC-20 Smart contract demonstrating how to create and transfer fungible tokens using an account-based model. README
Token UTXO Smart contract demonstrating how to create and transfer fungible tokens using a UTXO (unspent transaction output) model. README
High throughput Learn how you can design your smart contract to avoid transaction collisions in high volume environments. README
Auction Run an auction where bids are kept private until the auction is closed, after which users can reveal their bid README
Chaincode A set of other sample smart contracts, many of which were used in tutorials prior to the asset transfer sample series.
Interest rate swaps Deprecated in favor of state based endorsement asset transfer sample
Fabcar Deprecated in favor of basic asset transfer sample

License

Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/.