I want to implement Rust to call the contract method, but I encountered an error when connecting to the node

this is my cargo.toml :
[dependencies]

fuels = { version = “0.56.0”, features = [“fuel-core-lib”] }

tokio = { version = “1.28.2”, default-features = false }

This is the demo on the official website:
#[tokio::main]
async fn main(){
use std::str::FromStr;
use fuels::{accounts::{fuel_crypto::SecretKey,wallet::WalletUnlocked}, prelude::*};

// 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”)
.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());

}
The error is as follows:
thread ‘main’ panicked at src\main.rs:7:66:
called Result::unwrap() on an Err value: Provider("Server returned 404 Not Found: ")
stack backtrace:

2 Likes

Hello @lopo1 :wave:

The example in the docs has a comment, suggesting it’s expected to panic until testnet is updated to support the latest version of fuel-core.

Fuel Rust SDK | Fuel Docs

1 Like

I want to call the contract method above beta-5.fuel.network. How do I implement it?

1 Like

have you successfully deployed your contract ?

can you take a look how its done here on deploying and interacting with contracts:

Fuel Rust SDK | Fuel Docs
Fuel Rust SDK | Fuel Docs

1 Like

My main problem now is that I cannot connect to the rpc node of beta-5.fuel.network

Please share the error you get if any .

1 Like

// connect to the testnet.
let provider = Provider::connect(“beta-5.fuel.network”).await.unwrap();
#this error
→ called Result::unwrap() on an Err value: Provider("Server returned 404 Not Found: ")note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Sorry the error you are getting seems its a known issue.

The example in the latest documentation here, Fuel Rust SDK | Fuel Docs mention that this currently does not work as testnet needs to be updated.

// This example will not work as the testnet does not support the new version of fuel-core
// yet

Change it to the following one to use it normally:
fuels = { version = “0.55.0”, features = [“fuel-core-lib”] }

1 Like

nice project fuel go

2 Likes