Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Connecting to an External Node

Icon LinkConnecting to the Testnet or an external node

We can interact with the Testnet node by using the following example.

// #import { Provider, WalletUnlocked };
const provider = await Provider.create('https://beta-5.fuel.network/graphql');
// Setup a private key
const PRIVATE_KEY = 'a1447cd75accc6b71a976fd3401a1f6ce318d27ba660b0315ee6ac347bf39568';
 
// Create the wallet, passing provider
const wallet: WalletUnlocked = Wallet.fromPrivateKey(PRIVATE_KEY, provider);
 
const signer = new Signer(PRIVATE_KEY);
// validate address
expect(wallet.address).toEqual(signer.address);

In the code example, we connected a new provider to the Testnet node and created a new wallet from a private key.

Icon InfoCircle

Note: New wallets on the Testnet will not have any assets! They can be obtained by providing the wallet address to the faucet at

faucet-beta-5.fuel.network Icon Link

Once the assets have been transferred to the wallet, you can reuse it in other tests by providing the private key!

In addition to the faucet, there is a block explorer for the Testnet at

block-explorer Icon Link

If you want to connect to another node just change the URL or IP and port. For example, to connect to a local node that was created with fuel-core you can use:

// #import { Provider, WalletUnlocked, FUEL_NETWORK_URL };
const localProvider = await Provider.create(FUEL_NETWORK_URL);
// Setup a private key
const PRIVATE_KEY = 'a1447cd75accc6b71a976fd3401a1f6ce318d27ba660b0315ee6ac347bf39568';
 
// Create the wallet, passing provider
const wallet: WalletUnlocked = Wallet.fromPrivateKey(PRIVATE_KEY, localProvider);
 
const signer = new Signer(PRIVATE_KEY);
// validate address
expect(wallet.address).toEqual(signer.address);