Skip to content

Setting up test wallets

You'll often want to create one or more test wallets when testing your contracts. Here's how to do it.

Create a single wallet

ts
import type { WalletLocked, WalletUnlocked } from 'fuels';
import { Wallet } from 'fuels';

// We can use the `generate` to create a new unlocked wallet.
const myWallet: WalletUnlocked = Wallet.generate({ provider });

// or use an Address to create a wallet
const someWallet: WalletLocked = Wallet.fromAddress(myWallet.address, provider);
See code in context

Setting up multiple test wallets

If you need multiple test wallets, they can be set up using the launchTestNode utility. The wallets can be configured using the walletsConfig option. To understand the different configurations, check out the walletsConfig in the test node options guide.

ts
using launched = await launchTestNode({
  walletsConfig: {
    count: 3,
    assets: [AssetId.A, AssetId.B],
    coinsPerAsset: 5,
    amountPerCoin: 100_000,
  },
});

const {
  wallets: [wallet1, wallet2, wallet3],
} = launched;
See code in context