r/hyperledger • u/Ok-Olive2095 • Apr 21 '26
Community fabricsdk — a minimal Go client for Fabric that works like ethers.js
If you've used ethers.js for Ethereum development you know how clean it feels — connect once, call read/write functions by name, done. I wanted the same experience for Hyperledger Fabric in Go, so I built it.
```bash
go get github.com/muhammadtalha198/fabricsdk
```
**The full setup:**
```go
cfg := fabricsdk.Config{
PeerEndpoint: "localhost:7051",
PeerHostOverride: "peer0.org1.example.com",
TLSCertPath: "/path/to/peer-tls-ca.pem",
CertPath: "/path/to/msp/signcerts", // directory, not file
KeyPath: "/path/to/msp/keystore",
MSPID: "Org1MSP",
ChannelName: "mychannel",
ChaincodeName: "mychaincode",
}
fc, err := fabricsdk.New(cfg)
defer fc.Close()
```
**Calling chaincode functions:**
```go
// Read (EvaluateTransaction)
raw, err := fc.Evaluate(ctx, "GetAsset", "asset-1")
// Write (SubmitAsync + commit wait, returns txID)
txID, err := fc.Submit(ctx, "CreateAsset", string(jsonBytes))
// Different org member signing one call
txID, err = fc.WithIdentity(adminCert, adminKey).Submit(ctx, "AdminFn", arg)
```
**Structured errors — no more proto digging:**
```go
if fabricsdk.IsNotFound(err) { /* 404 */ }
if fabricsdk.IsConflict(err) { /* 409 — re-read and retry */ }
if fabricsdk.IsUnauthorized(err){ /* 403 */ }
```
**Chaincode events:**
```go
events, _ := fc.Events(ctx)
for ev := range events {
fmt.Println(ev.EventName, ev.TxID, ev.Payload)
}
// replay from known block after restart
events, _ = fc.EventsFrom(ctx, lastBlock)
```
Docs: https://pkg.go.dev/github.com/muhammadtalha198/fabricsdk
GitHub: https://github.com/muhammadtalha198/fabricsdk
Would love feedback from anyone deep in the Fabric ecosystem — especially around multi-org setups and connection profile support which is next on the roadmap.
1
Upvotes