pub struct TronRpcClient { /* private fields */ }Expand description
TRON Mainnet read-only JSON-RPC namespace.
The namespace deliberately exposes only the three read methods represented
by TRON_RPC_METHODS. JSON-RPC quantities and results remain raw strings;
in particular, no 41 prefix or Base58Check address conversion is applied.
Callers should use the documented interoperable 20-byte 0x hexadecimal
address form and the latest state selector.
A hosted root target is posted to /; the provider owns its upstream
/jsonrpc route. A caller-owned direct endpoint is the complete request
target, so a direct /jsonrpc suffix, encoded path, and query are retained
unchanged. The client is HTTP-only and has no REST, generic raw/request,
batch, subscription, transaction, signing, broadcast, swap, or bridge API.
The intentionally narrow surface has compile-fail coverage for forbidden escape hatches and state-changing operations:
let rpc = ErpcClient::new(ErpcClientConfig::new("key"))?.tron.rpc;
let _ = rpc.raw::<String>("eth_chainId", None);let rpc = ErpcClient::new(ErpcClientConfig::new("key"))?.tron.rpc;
let _ = rpc.request::<String>("eth_chainId", Vec::<serde_json::Value>::new());let rpc = ErpcClient::new(ErpcClientConfig::new("key"))?.tron.rpc;
let _ = rpc.batch(Vec::new());let rpc = ErpcClient::new(ErpcClientConfig::new("key"))?.tron.rpc;
let _ = rpc.subscribe("newHeads", Vec::new());let rpc = ErpcClient::new(ErpcClientConfig::new("key"))?.tron.rpc;
let _ = rpc.eth_send_raw_transaction(["0xdeadbeef"]);Implementations§
Source§impl TronRpcClient
impl TronRpcClient
Sourcepub fn endpoint(&self) -> String
pub fn endpoint(&self) -> String
Returns the credential-free TRON Mainnet JSON-RPC origin and root.
Sourcepub fn eth_chain_id(&self) -> PendingRpcRequest<String>
pub fn eth_chain_id(&self) -> PendingRpcRequest<String>
Creates a pending TRON Mainnet eth_chainId read.
§Panics
The empty parameter array is infallible to serialize.
Sourcepub fn eth_get_balance<P: Serialize>(
&self,
params: P,
) -> Result<PendingRpcRequest<String>>
pub fn eth_get_balance<P: Serialize>( &self, params: P, ) -> Result<PendingRpcRequest<String>>
Creates a pending positional TRON native balance read.
The raw JSON-RPC quantity is returned unchanged. TRON uses lowercase
sun as the native base unit; no TRX/sun scaling or conversion occurs.
Sourcepub fn eth_call<P: Serialize>(
&self,
params: P,
) -> Result<PendingRpcRequest<String>>
pub fn eth_call<P: Serialize>( &self, params: P, ) -> Result<PendingRpcRequest<String>>
Creates a pending read-only TRON eth_call simulation.
The caller’s 20-byte 0x hexadecimal address and latest selector are
serialized unchanged. This helper does not construct, sign, or submit
a transaction and does not promise archive-state support.