fabric-samples/asset-transfer-basic
2026-05-24 13:28:56 +08:00
..
application-gateway-go Update Go error handling for v1.10 client API (#1362) 2025-11-10 09:53:58 +09:00
application-gateway-java Update Go error handling for v1.10 client API (#1362) 2025-11-10 09:53:58 +09:00
application-gateway-javascript Update Go error handling for v1.10 client API (#1362) 2025-11-10 09:53:58 +09:00
application-gateway-typescript Bump the npm_and_yarn group across 9 directories with 1 update 2026-03-21 10:30:36 +00:00
chaincode-external Remove obsolete version element from compose files (#1361) 2025-11-04 10:52:28 -05:00
chaincode-go Bump the go_modules group across 17 directories with 2 updates (#1342) 2025-07-28 18:10:42 +01:00
chaincode-java Fix KIND cluster creation for test-network-k8s (#1375) 2026-02-09 10:16:42 +00:00
chaincode-javascript Update fabric-gateway to v1.8.0 (#1336) 2025-07-25 17:10:49 +09:00
chaincode-typescript Fix ESLint failures (#1386) 2026-02-26 13:20:40 +09:00
rest-api-go Update Go error handling for v1.10 client API (#1362) 2025-11-10 09:53:58 +09:00
rest-api-typescript Merge 0dec81adbe into a2c40e6522 2026-05-24 13:28:56 +08:00
.gitignore Adding NodeJS app for asset-transfer-basic sample. (#206) 2020-06-30 15:36:47 -04:00
README.md Add JavaScript asset-transfer-basic application 2024-06-21 12:16:31 -04:00

Asset transfer basic sample

The asset transfer basic sample demonstrates:

  • Connecting a client application to a Fabric blockchain network.
  • Submitting smart contract transactions to update ledger state.
  • Evaluating smart contract transactions to query ledger state.
  • Handling errors in transaction invocation.

About the sample

This sample includes smart contract and application code in multiple languages. This sample shows create, read, update, transfer and delete of an asset.

For a more detailed walk-through of the application code and client API usage, refer to the Running a Fabric Application tutorial in the main Hyperledger Fabric documentation.

Application

Follow the execution flow in the client application code, and corresponding output on running the application. Pay attention to the sequence of:

  • Transaction invocations (console output like "--> Submit Transaction" and "--> Evaluate Transaction").
  • Results returned by transactions (console output like "*** Result").

Smart Contract

The smart contract (in folder chaincode-xyz) implements the following functions to support the application:

  • CreateAsset
  • ReadAsset
  • UpdateAsset
  • DeleteAsset
  • TransferAsset

Note that the asset transfer implemented by the smart contract is a simplified scenario, without ownership validation, meant only to demonstrate how to invoke transactions.

Running the sample

The Fabric test network is used to deploy and run this sample. Follow these steps in order:

  1. Create the test network and a channel (from the test-network folder).

    ./network.sh up createChannel -c mychannel -ca
    
  2. Deploy one of the smart contract implementations (from the test-network folder).

    • To deploy the TypeScript chaincode implementation:

      ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-typescript/ -ccl typescript
      
    • To deploy the JavaScript chaincode implementation:

      ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-javascript/ -ccl javascript
      
    • To deploy the Go chaincode implementation:

      ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go/ -ccl go
      
    • To deploy the Java chaincode implementation:

      ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-java/ -ccl java
      
  3. Run the application (from the asset-transfer-basic folder).

    • To run the TypeScript sample application:

      cd application-gateway-typescript
      npm install
      npm start
      
    • To run the JavaScript sample application:

      cd application-gateway-javascript
      npm install
      npm start
      
    • To run the Go sample application:

      cd application-gateway-go
      go run .
      
    • To run the Java sample application:

      cd application-gateway-java
      ./gradlew run
      

Clean up

When you are finished, you can bring down the test network (from the test-network folder). The command will remove all the nodes of the test network, and delete any ledger data that you created.

./network.sh down