Connecting to an external Fuel node
If you want your SDK code to connect to an already running Fuel node, which could be devnet, testnet, mainnet, or a local instance through fuel-core
, this is how you do it:
use fuels::prelude::*;
// This is the address of a running node.
let server_address: SocketAddr = "127.0.0.1:4000"
.parse()
.expect("Unable to parse socket address");
// Create the provider using the client.
let provider = Provider::connect(server_address).await.unwrap();
// Create the wallet.
let _wallet = WalletUnlocked::new_random(Some(provider));