Skip to content

Advanced Example

A more complex example showcasing genesis block state configuration with walletsConfig and deployment of multiple contracts is shown below.

ts
import { AssetId, TestMessage, launchTestNode } from 'fuels/test-utils';

import { TestContract__factory } from 'path/to/typegen/output';
import bytecode from 'path/to/typegen/output/TestContract.hex.ts';

const assets = AssetId.random(2);
const message = new TestMessage({ amount: 1000 });

using launched = await launchTestNode({
  walletsConfig: {
    count: 4,
    assets,
    coinsPerAsset: 2,
    amountPerCoin: 1_000_000,
    messages: [message],
  },
  contractsConfigs: [
    {
      deployer: TestContract__factory,
      bytecode,
      walletIndex: 3,
      options: { storageSlots: [] },
    },
  ],
});

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

Summary

  1. All points listed in the basic example apply here as well.
  2. Multiple wallets were generated with highly-specific coins and messages.
  3. It's possible to specify the wallet to be used for contract deployment via walletIndex.
  4. The test contract can be deployed with all the options available for real contract deployment.