You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to connect to a public network but while I do so using an API, it throws the error:
thread 'main' panicked at 'there is no reactor running, must be called from the context of a Tokio 1.x runtime', /Users/aviralsrivastava/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.14.0/src/runtime/context.rs:54:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I set the URL and the port in a typical format in my code:
let api = ClientBuilder::new()
.set_url("wss://pub.elara.patract.io:9944/statemine")
.build()
.await?
.to_runtime_api::<polkadot::RuntimeApi<polkadot::DefaultConfig>>();
I tried to take a look at the source code for ClientBuilder:
let url = self.url.as_deref().unwrap_or("ws://127.0.0.1:9944");
The format is the same as in my code.
My MVC:
use subxt::ClientBuilder;
#[subxt::subxt(runtime_metadata_path = "polkadot_metadata.scale")]
pub mod polkadot {}
#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
let api = ClientBuilder::new()
.set_url("wss://pub.elara.patract.io:9944/statemine")
.build()
.await?
.to_runtime_api::<polkadot::RuntimeApi<polkadot::DefaultConfig>>();
let mut iter = api.storage().system().account_iter(None).await?;
while let Some((key, account)) = iter.next().await? {
println!("{}: {}", hex::encode(key), account.data.free);
}
Ok(())
}
My Cargo.toml:
[package]
name = "my-package"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
subxt = { git = "https://github.com/paritytech/subxt/" }
async-std = {version = "1.10.0", features = ["attributes"]}
env_logger = "0.9.0"
async-trait = "0.1.49"
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full", "bit-vec"] }
chameleon = "0.1.0"
scale-info = { version = "1.0.0", features = ["bit-vec"] }
futures = "0.3.13"
hex = "0.4.3"
jsonrpsee = { version = "0.5.1", features = ["macros", "ws-client", "http-client"] }
log = "0.4.14"
num-traits = { version = "0.2.14", default-features = false }
serde = { version = "1.0.124", features = ["derive"] }
serde_json = "1.0.64"
thiserror = "1.0.24"
url = "2.2.1"
How do I configure my own URL to use the subxt library?
The text was updated successfully, but these errors were encountered:
I want to connect to a public network but while I do so using an API, it throws the error:
I set the URL and the port in a typical format in my code:
I tried to take a look at the source code for ClientBuilder:
The format is the same as in my code.
My MVC:
My Cargo.toml:
How do I configure my own URL to use the subxt library?
The text was updated successfully, but these errors were encountered: