Crates.io | eth_rpc |
lib.rs | eth_rpc |
version | 0.2.6 |
source | src |
created_at | 2023-08-07 07:58:45.309708 |
updated_at | 2023-11-13 19:49:30.919767 |
description | simple eth rpc with helper functions |
homepage | https://github.com/copiumnicus/eth_rpc |
repository | https://github.com/copiumnicus/eth_rpc |
max_upload_size | |
id | 937752 |
size | 59,086 |
eth_rpc is a simple, portable eth rpc (partial) implementation with features like:
AccountInfo
modelAll calls under the hood (EXCEPT TX SUBMISSION FOR FULL CONTROL) use no ratelimit rpc
pub fn no_ratelimit_rpc<R>(&self, jr: JRCall) -> Result<R, JRError>
where
R: for<'a> Deserialize<'a>,
The abigen compatible eth call:
/// simple wrapper on top of eth call to work with abigen! macro
pub fn eth_call_typed<R>(&self, to: H160, calldata: impl AbiEncode) -> Result<R, JRError>
where
R: AbiDecode,
The json rpc (chunked) batching compatibility:
/// in case of error returns first JRError encountered
pub fn batch(&self, requests: Vec<JRCall>) -> Result<Vec<SafeJRResult>, JRError>
Erc20 helpers:
pub fn get_balance(&self, token: H160, account: H160) -> Result<U256, JRError>;
pub fn get_decimals(&self, token: H160) -> Result<u8, JRError>;
pub fn get_symbol(&self, token: H160) -> Result<String, JRError>;
/// for MKR token
pub fn get_bytes32_symbol(&self, token: H160) -> Result<String, JRError>;
Custom tx submit error (will handle more based on downstream demand)
#[derive(Debug)]
pub enum SubmitTxError {
JRErr(JRError),
NonceTooLow,
ReplacementUnderpriced,
BaseGasPriceTooLow(String),
}
Example rpc serialized (json) config (uses all https randomly under the hood):
{
"batch_chunk_size": 5,
"transport": {
"RandomizeHttps": [
"https://omniscient-few-darkness.quiknode.pro/fake0/",
"https://eth-mainnet.g.alchemy.com/v2/fake1",
"https://eth-mainnet.g.alchemy.com/v2/fake2",
"https://eth-mainnet.g.alchemy.com/v2/fake3"
]
}
}
Functions for:
Populate the source_env.sh
based on source_env_example.sh
and run the tests with sh ./regression.sh