fabric-samples icon indicating copy to clipboard operation
fabric-samples copied to clipboard

feat: add Go client application for full-stack-asset-transfer-guide

Open nXtCyberNet opened this issue 8 months ago • 0 comments

Closes: #1378

Summary

This PR adds a Go implementation of the full-stack-asset-transfer-guide client application, mirroring the existing TypeScript implementation in trader-typescript.

What's Included

A new directory: trader-go

main.go Entry point. Parses CLI arguments, establishes the gRPC connection, and dispatches commands.

connect.go Creates the gRPC connection and initializes the Fabric Gateway client.

contract.go Defines the AssetTransfer struct that wraps all smart contract calls (CreateAsset, ReadAsset, UpdateAsset, DeleteAsset, TransferAsset, GetAllAssets).

commands.go Command registry mapping CLI command names to handler functions.

commands_impl.go Implementation of all commands (create, delete, getAllAssets, listen, read, transact, transfer).

config.go Helper functions for reading environment variables (ENDPOINT, MSP_ID, CERTIFICATE, PRIVATE_KEY, CHANNEL_NAME, CHAINCODE_NAME).

expectedError.go Defines the ExpectedError type to distinguish known application errors from unexpected failures.

go.mod / go.sum Module definition using fabric-gateway v1.10.0 and grpc v1.76.0.

Usage

The CLI interface is identical to the TypeScript implementation.

Testing

Tested end-to-end in WSL against a live Microfab network with the asset-transfer-typescript chaincode.

All 7 commands execute successfully.

nXtCyberNet avatar Mar 11 '26 16:03 nXtCyberNet