このページは、お客様の言語ではご利用いただけません。Huawei Cloudは、より多くの言語バージョンを追加するために懸命に取り組んでいます。ご協力ありがとうございました。
Web3 Node Engine Service
Web3 Node Engine Service
- What's New
- Service Overview
- Getting Started
- User Guide
- User Guide (Staking Nodes)
-
Developer Guide
-
Ethereum Node Engine
- Introduction
- JSON-RPC API Request Examples
- Application Development
- Smart Contract Development
-
Ethereum APIs
- Dedicated Edition
-
Shared Edition
- eth_blocknumber
- eth_getBlockByNumber
- eth_getUncleByBlockNumberAndIndex
- eth_getUncleByBlockHashAndIndex
- eth_getUncleCountByBlockNumber
- eth_getUncleCountByBlockHash
- eth_getBlockByHash
- eth_getTransactionByHash
- eth_getTransactionCount
- eth_getTransactionByBlockHashAndIndex
- eth_getTransactionByBlockNumberAndIndex
- eth_getBlockTransactionCountByHash
- eth_getBlockTransactionCountByNumber
- eth_getTransactionReceipt
- eth_sendRawTransaction
- eth_call
- eth_createAccessList
- eth_estimateGas
- eth_feeHistory
- eth_maxPriorityFeePerGas
- eth_gasPrice
- eth_getBalance
- eth_subscribe
- eth_unsubscribe
- eth_getStorageAt
- eth_getCode
- eth_getProof
- eth_getLogs
- eth_getFilterChanges
- eth_getFilterLogs
- eth_newBlockFilter
- eth_newFilter
- eth_newPendingTransactionFilter
- eth_uninstallFilter
- eth_chainId
- web3_sha3
- web3_clientVersion
- net_version
- net_listening
- TRON Node Engine
-
Polygon PoS
- Polygon PoS Introduction
- HTTP Request Examples
- WebSocket Request Examples
-
Polygon PoS APIs
- Dedicated Edition
-
Shared Edition
-
Ethereum JSON-RPC APIs
- eth_blocknumber
- eth_getBlockByNumber
- eth_getUncleByBlockNumberAndIndex
- eth_getUncleByBlockHashAndIndex
- eth_getUncleCountByBlockNumber
- eth_getUncleCountByBlockHash
- eth_getBlockByHash
- eth_getTransactionByHash
- eth_getTransactionCount
- eth_getTransactionByBlockHashAndIndex
- eth_getTransactionByBlockNumberAndIndex
- eth_getBlockTransactionCountByHash
- eth_getBlockTransactionCountByNumber
- eth_getTransactionReceiptsByBlock
- eth_getTransactionReceipt
- eth_sendRawTransaction
- eth_call
- eth_createAccessList
- eth_estimateGas
- eth_feeHistory
- eth_maxPriorityFeePerGas
- eth_gasPrice
- eth_getBalance
- eth_getRootHash
- eth_subscribe
- eth_unsubscribe
- eth_getStorageAt
- eth_accounts
- eth_getCode
- eth_getProof
- eth_getLogs
- eth_getFilterChanges
- eth_getFilterLogs
- eth_newBlockFilter
- eth_newFilter
- eth_newPendingTransactionFilter
- eth_uninstallFilter
- eth_chainId
- web3_sha3
- web3_clientVersion
- Polygon JSON-RPC APIs
-
Ethereum JSON-RPC APIs
-
Arbitrum
- Arbitrum Introduction
- HTTP Request Examples
- WebSocket Request Examples
-
Arbitrum APIs
-
Shared Edition
-
Ethereum JSON-RPC APIs
- eth_blocknumber
- eth_getBlockByNumber
- eth_getUncleByBlockNumberAndIndex
- eth_getUncleByBlockHashAndIndex
- eth_getUncleCountByBlockNumber
- eth_getUncleCountByBlockHash
- eth_getBlockByHash
- eth_getTransactionByHash
- eth_getTransactionCount
- eth_getTransactionByBlockHashAndIndex
- eth_getTransactionByBlockNumberAndIndex
- eth_getBlockTransactionCountByHash
- eth_getBlockTransactionCountByNumber
- eth_syncing
- eth_getTransactionReceipt
- eth_sendRawTransaction
- eth_call
- eth_createAccessList
- eth_estimateGas
- eth_feeHistory
- eth_maxPriorityFeePerGas
- eth_gasPrice
- eth_getBalance
- eth_subscribe
- eth_unsubscribe
- eth_getStorageAt
- eth_accounts
- eth_getCode
- eth_getProof
- eth_getLogs
- eth_getFilterChanges
- eth_getFilterLogs
- eth_newBlockFilter
- eth_newFilter
- eth_newPendingTransactionFilter
- eth_uninstallFilter
- eth_chainId
- web3_sha3
- web3_clientVersion
-
Ethereum JSON-RPC APIs
-
Shared Edition
-
BNB Smart Chain
- BNB Smart Chain Introduction
- HTTP Request Examples
- WebSocket Request Examples
-
BNB Smart Chain APIs
- Dedicated Edition
-
Shared Edition
- eth_blocknumber
- eth_getBlockByNumber
- eth_hashrate
- eth_getUncleCountByBlockNumber
- eth_getUncleCountByBlockHash
- eth_getBlockByHash
- eth_getTransactionByHash
- eth_getTransactionCount
- eth_getTransactionByBlockHashAndIndex
- eth_getTransactionByBlockNumberAndIndex
- eth_getBlockTransactionCountByHash
- eth_getBlockTransactionCountByNumber
- eth_syncing
- eth_getTransactionReceipt
- eth_sendRawTransaction
- eth_call
- eth_mining
- eth_estimateGas
- eth_feeHistory
- eth_maxPriorityFeePerGas
- eth_gasPrice
- eth_getBalance
- eth_subscribe
- eth_unsubscribe
- eth_getStorageAt
- eth_accounts
- eth_getCode
- eth_getProof
- eth_getLogs
- eth_getFilterChanges
- eth_getFilterLogs
- eth_newBlockFilter
- eth_newFilter
- eth_newPendingTransactionFilter
- eth_uninstallFilter
- eth_chainId
- web3_sha3
- web3_clientVersion
- txpool_status
- net_listening
- net_version
- Batch Requests
-
Ethereum Node Engine
- API Reference
-
FAQs
-
APIs
- How Do I Determine Whether Flow Control Is Triggered for an API?
- What Are the Flow Control Policies for Full Nodes?
- How Many Methods Can Be Included in a JSON-RPC Batch Request for the Dedicated Version?
- How Many WebSocket Connections Can Be Made Each Time?
- How Do I Use HTTP Endpoints and Authentication Credentials to Access Nodes?
- Staking Nodes
-
APIs
- General Reference
On this page
Show all
Help Center/
Web3 Node Engine Service/
Developer Guide/
TRON Node Engine/
gRPC Request Examples/
Using TridentSDK to Send gRPC Requests
Copied.
Using TridentSDK to Send gRPC Requests
TridentSDK of the version 0.7.0 and earlier is supported. Currently, you cannot send gRPC requests using TLS. Therefore, perform node interconnection with Java reflection according to the sample code.
Download the certificate on the node details page and place the ca.crt certificate in the package under the project directory.
Configure the gRPC endpoint in the SDK. The sample code is as follows:
import io.gRPC.*; import io.gRPC.stub.MetadataUtils; import org.tron.trident.api.WalletgRPC; import org.tron.trident.api.WalletSoliditygRPC; import org.tron.trident.core.ApiWrapper; import org.tron.trident.core.exceptions.IllegalException; import org.tron.trident.core.key.KeyPair; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; public class Main { public static void main(String[] args) throws IllegalException, IOException, NoSuchFieldException, IllegalAccessException { String gRPCEndpoint = "your-gRPC-endpoint"; String gRPCSolidityEndpoint = "your-gRPCsolidity-endpoint"; String credential = "your-credential"; String hexPrivateKey = "your-hex-private-key"; ApiWrapper wrapper = new ApiWrapper(gRPCEndpoint, gRPCSolidityEndpoint, hexPrivateKey, credential); // modify wallet channel through reflex ChannelCredentials creds = TlsChannelCredentials.newBuilder() .trustManager(new File("your-ca.crt-file-path")) .build(); ManagedChannel channel = gRPC.newChannelBuilder(gRPCEndpoint, creds) .build(); Metadata header = new Metadata(); Metadata.Key<String> key = Metadata.Key.of("TRON-PRO-API-KEY", Metadata.ASCII_STRING_MARSHALLER); header.put(key, credential); setField(ApiWrapper.class, wrapper, "channel", channel); setField(ApiWrapper.class, wrapper, "blockingStub", MetadataUtils.attachHeaders(WalletgRPC.newBlockingStub(channel), header)); // modify walletsolidity channel through reflex ManagedChannel channelSolidity = gRPC.newChannelBuilder(gRPCSolidityEndpoint, creds) .build(); setField(ApiWrapper.class, wrapper, "channelSolidity", channelSolidity); setField(ApiWrapper.class, wrapper, "blockingStubSolidity", MetadataUtils.attachHeaders(WalletSoliditygRPC.newBlockingStub(channelSolidity), header)); // getNowBlock & getNowBlockSolidity test System.out.println(wrapper.getNowBlock()); System.out.println(wrapper.getNowBlockSolidity()); System.out.println("finish"); } private static void setField(Class clazz, Object obj, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException { Field field = clazz.getDeclaredField(fieldName); field.setAccessible(true); field.set(obj, value); } }
Response example
Parent topic: gRPC Request Examples
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.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot