Expand description
§fabric-gateway
A Rust client for the Hyperledger Fabric Gateway, ported from the official
fabric-gateway-go client
package. It lets applications evaluate (query) and submit (update)
transactions against chaincode deployed to a Fabric network, connecting
through a peer’s embedded Gateway service.
§Programming model
The type hierarchy mirrors the Go library:
Gateway → Network (a channel) → Contract (a chaincode) →
Proposal → Transaction → Commit.
use fabric_gateway::{Gateway, Identity, identity::EcdsaP256Signer};
use std::sync::Arc;
let channel = tonic::transport::Channel::from_static("https://peer:7051")
.connect()
.await?;
let identity = Identity::new("Org1MSP", std::fs::read("cert.pem")?);
let signer = Arc::new(EcdsaP256Signer::from_pem(&std::fs::read_to_string("key.pem")?)?);
let gateway = Gateway::connect(identity, signer, channel)?;
let contract = gateway.get_network("mychannel").get_contract("basic");
let result = contract.evaluate_transaction("GetAllAssets", &[]).await?;
println!("{}", String::from_utf8_lossy(&result));§Wire-compatibility
Proposals, transactions and commit-status requests are serialised with the
same protobuf layout, transaction-ID derivation
(hex(sha256(nonce || creator))), SHA-256 digesting and low-S ASN.1-DER
ECDSA signing as fabric-gateway-go, so signatures verify on the peer.
Re-exports§
pub use error::GatewayError;pub use error::TransactionError;pub use identity::EcdsaP256Signer;pub use identity::Identity;pub use identity::Signer;
Modules§
- error
- Error types mirroring fabric-gateway-go’s
clienterror hierarchy. - hash
- Hash implementations used to create digests for digital signatures.
- identity
- Client identity and signing implementations.
- pb
- Generated protobuf modules for the Fabric Gateway wire protocol.
Structs§
- Block
Events Builder - Builder for block / filtered-block event requests. Ports the
baseBlockEventsBuilderseek-envelope construction. - Block
Events Request - Streams full block events from the peer’s Deliver service.
- Chaincode
Event - A chaincode event emitted by a transaction function.
- Chaincode
Events Builder - Builder for a chaincode-events request, supporting a custom start position.
- Chaincode
Events Request - A signed request that streams chaincode events.
- Commit
- Provides access to the commit status of a transaction.
- Contract
- Represents a smart contract, allowing evaluation (query) and submission (ledger update) of transactions.
- Filtered
Block Events Request - Streams filtered block events from the peer’s Deliver service.
- Gateway
- A connection of a specific client identity to a Fabric Gateway.
- Gateway
Builder - Builder for a
Gateway, mirroring the GoConnectOptionfunctions. - Network
- Represents a network of nodes that are members of a specific Fabric channel. Obtain contracts and (in future) subscribe to events through it.
- Proposal
- A transaction proposal that can be endorsed (submit flow) or evaluated
(query). Supports the off-line signing flow via
Proposal::bytes,Proposal::digestandcrate::Gateway::new_signed_proposal. - Proposal
Builder - Builder for a transaction
Proposal. Obtain one viacrate::Contract::new_proposal. - Status
- Status of a committed transaction.
- Transaction
- An endorsed transaction, ready to submit to the ordering service.