I tried to access the latest test network and got a 404 prompt. Is there something wrong with my rpc? Where should I find the correct rpc, which I copied from the wallet.
use std::str::FromStr;
use fuels::{crypto::SecretKey, prelude::*};
use tokio::runtime;
async fn wallet() {
// let rpc_url = "beta-5.fuel.network/graphql";
let rpc_url = "testnet.fuel.network/v1/graphql";
// Create a provider pointing to the testnet.
// This example will not work as the testnet does not support the new version of fuel-core
// yet
let provider = Provider::connect(rpc_url).await.unwrap();
// Setup a private key
let secret =
SecretKey::from_str("xxxxxxxx")
.unwrap();
// Create the wallet
let wallet = WalletUnlocked::new_from_private_key(secret, Some(provider));
// Get the wallet address. Used later with the faucet
dbg!(wallet.address().to_string());
let balances = wallet.get_balances().await.unwrap();
dbg!(balances);
}
fn main() {
let rt = runtime::Runtime::new().unwrap();
rt.block_on(wallet());
}
thread 'main' panicked at src/main.rs:14:53:
called `Result::unwrap()` on an `Err` value: IOError(Custom { kind: Other, error: ErrorResponse(404, "") })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Can you please include more context around what code you are trying to run (link to code or gist) and what your fuelup show result is and what version of the SDK you have installed in your project?
I’ll have the team look into this for what we can and get back to you shortly.
use std::str::FromStr;
use fuels::{crypto::SecretKey, prelude::*};
use tokio::runtime;
async fn wallet() {
// let rpc_url = "beta-5.fuel.network/graphql";
let rpc_url = "testnet.fuel.network/v1/graphql";
// Create a provider pointing to the testnet.
// This example will not work as the testnet does not support the new version of fuel-core
// yet
let provider = Provider::connect(rpc_url).await.unwrap();
// Setup a private key
let secret =
SecretKey::from_str("xxxxxxxx")
.unwrap();
// Create the wallet
let wallet = WalletUnlocked::new_from_private_key(secret, Some(provider));
// Get the wallet address. Used later with the faucet
dbg!(wallet.address().to_string());
let balances = wallet.get_balances().await.unwrap();
dbg!(balances);
}
fn main() {
let rt = runtime::Runtime::new().unwrap();
rt.block_on(wallet());
}
Cargo.toml
[package]
name = "hello_fuel"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
fuels = { version = "0.55.0", features = ["fuel-core-lib"] }
tokio = { version = "1.4", features = ["full"] }