Guest User

Untitled

a guest
Dec 14th, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. use jsonrpsee_ws_client::WsClientBuilder;
  2. use std::time::Duration;
  3. use subxt::ClientBuilder;
  4.  
  5. #[subxt::subxt(runtime_metadata_path = "polkadot_metadata.scale")]
  6. pub mod polkadot {}
  7.  
  8. #[async_std::main]
  9. async fn main() -> Result<(), Box<dyn std::error::Error>> {
  10. env_logger::init();
  11. // let connection_timeout_secs = Duration::new(secs: 60, nanos: 0);
  12. let connection_timeout_duration = Duration::new(600, 0);
  13.  
  14. let url = "wss://moonriver.api.onfinality.io:9944/public-ws";
  15.  
  16. let client = WsClientBuilder::default()
  17. .connection_timeout(connection_timeout_duration)
  18. .build(url)
  19. .await
  20. .ok();
  21.  
  22. println!("Client established.");
  23.  
  24. let client = client.unwrap();
  25.  
  26. // let api = ClientBuilder::new()
  27. // .set_client(client)
  28. // // .set_url("wss://pub.elara.patract.io:9944/statemine")
  29. // .build()
  30. // .await?
  31. // .to_runtime_api::<polkadot::RuntimeApi<polkadot::DefaultConfig>>();
  32.  
  33. // let mut iter = api.storage().system().account_iter(None).await?;
  34.  
  35. // while let Some((key, account)) = iter.next().await? {
  36. // println!("{}: {}", hex::encode(key), account.data.free);
  37. // }
  38. Ok(())
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment