Can't connect to fule node with rust sdk

use std::str::FromStr;

use fuels::prelude::{FuelService, Provider};
use fuels::{crypto::SecretKey, prelude::*};

#[tokio::main]
async fn main() -> Result<()> {
    println!("Hello, world!");

    // Create a provider pointing to the testnet.
    let provider = Provider::connect("beta-5.fuel.network").await.unwrap();

    // Setup a private key
    let secret =
        SecretKey::from_str("a1447cd75accc6b71a976fd3401a1f6ce318d27ba660b0315ee6ac347bf39568")?;

    // Create the wallet
    let wallet = WalletUnlocked::new_from_private_key(secret, Some(provider));

    println!("{}", wallet.address().to_string());
    Ok(())
}

Output;
╰─$ cargo run 130 ↵
Compiling FuleRustScripts v0.1.0
warning: unused import: FuelService
→ src/main.rs:3:22
|
3 | use fuels::prelude::{FuelService, Provider};
| ^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

warning: crate FuleRustScripts should have a snake case name
|
= help: convert the identifier to snake case: fule_rust_scripts
= note: #[warn(non_snake_case)] on by default

warning: FuleRustScripts (bin “FuleRustScripts”) generated 2 warnings (run cargo fix --bin "FuleRustScripts" to apply 1 suggestion)
Finished dev [unoptimized + debuginfo] target(s) in 1.48s
Running target/debug/FuleRustScripts
Hello, world!
thread ‘main’ panicked at src/main.rs:11:67:
called Result::unwrap() on an Err value: IO("Server returned 404 Not Found: ")
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Version:

[dependencies]
fuels = “0.64.0”
tokio = { version = “1”, features = [“full”] }

Hey @markwh1te, thanks for pointing it out. The Provider is trying to connect to the wrong URL, the beta-5 network is deprecated and thus its having problems with the connectivity. The correct node URL is testnet.fuel.network. lmk how it goes

@Nazeeh21 Thank you, it’s working perfectly!
By the way, may I ask if there is any way I can contribute to the documentation? I would like to correct this error in the docs.

1 Like

If you’re interested, you can make the PR to this repo by following the contribution guide

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.