Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Setting Up a Custom Chain

Icon LinkSetting up a custom chain

The launchNodeAndGetWallets method lets you launch a local Fuel node with various customizations.

In the code snippet below, we provide a custom chain config file to the launchNodeAndGetWallets method. You can use a chain config file to customize things like the chain's consensus parameters or specify some initial states for the chain. Click here to see what a chain config file looks like: chainConfig.json Icon Link

const chainConfigPath = path.join(cwd(), '.fuel-core/configs/chainConfig.json');
 
const { stop, provider } = await launchNodeAndGetWallets({
	launchNodeOptions: {
	args: ['--chain', chainConfigPath],
	loggingEnabled: false,
	},
});
 
const {
	consensusParameters: { gasPerByte },
} = provider.getChain();
 
expect(gasPerByte.toNumber()).toEqual(4);
 
stop();

Icon LinkCustomization options

As you can see in the previous code snippet, you can optionally pass in a walletCount and some launchNodeOptions to the launchNodeAndGetWallets method.

The walletCount option lets you specify how many wallets you want to generate. The default value is 10.

The launchNodeOptions option lets you specify some additional options for the node. The available options are:

/**
 * Launches a fuel-core node.
 * @param ip - the ip to bind to. (optional, defaults to 0.0.0.0)
 * @param port - the port to bind to. (optional, defaults to 4000 or the next available port)
 * @param args - additional arguments to pass to fuel-core.
 * @param useSystemFuelCore - whether to use the system fuel-core binary or the one provided by the \@fuel-ts/fuel-core package.
 * @param loggingEnabled - whether the node should output logs. (optional, defaults to true)
 * @param debugEnabled - whether the node should log debug messages. (optional, defaults to false)
 * @param basePath - the base path to use for the temporary folder. (optional, defaults to os.tmpdir())
 * */
Icon InfoCircle

Note: You can see all the available fuel-core args by running pnpm fuels core run -h.