Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use hyper::{self, client::HttpConnector};
- #[derive(Clone)]
- pub struct Client {
- project_id: String,
- inner_client: hyper::Client<HttpConnector>,
- }
- impl Client {
- pub fn new(project_id: String) -> Self {
- Client {
- project_id: project_id,
- inner_client: hyper::Client::new(),
- }
- }
- pub async fn get_price_in_pool(&self, pool_address: String, func_hash: String) {
- let url = format!("https://mainnet.infura.io/v3/{}", self.project_id);
- let req = hyper::Request::builder()
- .method(hyper::Method::POST)
- .uri(url)
- .header("content-type", "application/json")
- .body(hyper::Body::from(r#"{
- "jsonrpc":"2.0",
- "method":"eth_call",
- "params":[{
- "to": "0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640",
- "data": "0x3850c7bd"
- },"latest"],
- "id":1
- }"#))
- .unwrap();
- let resp = self.inner_client.request(req).await;
- }
- }
- fn main() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement