Option<Provider>
. use fuels::prelude::*;
// Use the test helper to setup a test provider.
let provider = setup_test_provider(vec![], vec![], None, None).await?;
// Create the wallet.
let _wallet = WalletUnlocked::new_random(Some(provider));
SecretKey
. use std::str::FromStr;
use fuels::{crypto::SecretKey, prelude::*};
// Use the test helper to setup a test provider.
let provider = setup_test_provider(vec![], vec![], None, None).await?;
// Setup the private key.
let secret = SecretKey::from_str(
"5f70feeff1f229e4a95e1056e8b4d80d0b24b565674860cc213bdb07127ce1b1",
)?;
// Create the wallet.
let _wallet = WalletUnlocked::new_from_private_key(secret, Some(provider));
Note: ifNone
is supplied instead of a provider, any transaction related to the wallet will result in an error until a provider is linked withset_provider()
. The optional parameter enables defining owners (wallet addresses) of genesis coins before a provider is launched.