Gateway Java Demo
This section provides a demo based on Fabric Gateway for Java. Fabric Gateway Java encapsulates the Java SDK, which reduces the code amount and helps users develop Java client applications.
Common APIs
When you use Fabric-Gateway-Java to initiate transactions and query data, the Network and Contract interfaces are used. For more interfaces, see the Fabric official website.
- Network
The common interfaces are as follows:
API
Description
Setting
Returned Values
getContract
Gets an instance of a contract.
String chaincodeId
Contract
addBlockListener
Adds a listener to listen to block events.
Consumer<org.hyperledger.fabric.sdk.BlockEvent> listener
Consumer<org.hyperledger.fabric.sdk.BlockEvent>
getChannel
Gets the channel associated with the network.
/
org.hyperledger.fabric.sdk.Channel
removeBlockListener
Removes a listener.
Consumer<org.hyperledger.fabric.sdk.BlockEvent> listener
void
- Contract
The common interfaces are as follows:
API
Description
Setting
Returned Values
submitTransaction
Submits a transaction. The invocation method and parameters need to be entered.
String name, String... args
byte[]
evaluateTransaction
Evaluates a transaction. The invocation method and parameters need to be entered.
String name, String... args
byte[]
createTransaction
Creates a transaction. The transaction needs to be submitted.
String name
Transaction
addContractListener
Adds a listener to listen to events emitted by committed transactions.
Consumer<ContractEvent> listener
Consumer<ContractEvent> listener
removeContractListener
Removes a listener.
Consumer<ContractEvent> listener
void
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot