FuelLabs/fuels-ts · error · FuelError
INVALID_INPUT_PARAMETERS
INVALID_INPUT_PARAMETERS
Error message
Invalid walletIndex ${config.walletIndex}; wallets array contains ${wallets.length} elements. What it means
Thrown by getWalletForDeployment() (packages/contract/src/test-utils/launch-test-node.ts:130) when config.walletIndex is negative or greater than or equal to the number of wallets generated by the test node launcher. This is a test-utility function that selects which wallet from the generated wallet array should be used to deploy a contract in a test scenario.
Source
Thrown at packages/contract/src/test-utils/launch-test-node.ts:130
function getFuelCoreArgs<TFactories extends DeployContractConfig[]>(
nodeOptions: LaunchTestNodeOptions<TFactories>['nodeOptions']
) {
const envArgs = process.env.DEFAULT_FUEL_CORE_ARGS
? process.env.DEFAULT_FUEL_CORE_ARGS.split(' ')
: undefined;
return nodeOptions?.args ?? envArgs;
}
function getWalletForDeployment(config: DeployContractConfig, wallets: WalletUnlocked[]) {
if (!('walletIndex' in config) || !config.walletIndex) {
return wallets[0];
}
const validWalletIndex = config.walletIndex >= 0 && config.walletIndex < wallets.length;
if (!validWalletIndex) {
throw new FuelError(
FuelError.CODES.INVALID_INPUT_PARAMETERS,
`Invalid walletIndex ${config.walletIndex}; wallets array contains ${wallets.length} elements.`
);
}
return wallets[config.walletIndex];
}
export async function launchTestNode<const TFactories extends DeployContractConfig[]>({
providerOptions = {},
walletsConfig = {},
nodeOptions = {},
contractsConfigs,
}: Partial<LaunchTestNodeOptions<TFactories>> = {}): Promise<LaunchTestNodeReturn<TFactories>> {
const snapshotConfig = getChainSnapshot(nodeOptions);
const args = getFuelCoreArgs(nodeOptions);
const { provider, wallets, cleanup } = await setupTestProviderAndWallets({
walletsConfig,View on GitHub (pinned to b3f37c91ac)
Solutions
- Ensure walletIndex is 0-indexed and less than walletsConfig.count (default 10).
- Increase walletsConfig.count to accommodate the desired walletIndex.
- Omit walletIndex to default to wallets[0].
Example fix
// before
const { contracts } = await launchTestNode({
walletsConfig: { count: 5 },
contractsConfigs: [{ factory, walletIndex: 7 }],
});
// after
const { contracts } = await launchTestNode({
walletsConfig: { count: 10 },
contractsConfigs: [{ factory, walletIndex: 7 }],
}); Defensive patterns
Strategy: validation
Validate before calling
const walletCount = 10; // must match walletsConfig.count
const walletIndex = config.walletIndex ?? 0;
if (walletIndex < 0 || walletIndex >= walletCount) {
throw new Error(`walletIndex ${walletIndex} out of range [0, ${walletCount - 1}]`);
}
// Use in contractsConfigs Type guard
function isValidWalletIndex(index: number, walletCount: number): boolean {
return Number.isInteger(index) && index >= 0 && index < walletCount;
} Prevention
- Remember walletIndex is 0-indexed; valid range is [0, walletsConfig.count - 1].
- Set walletsConfig.count high enough to accommodate all walletIndex references.
- Omit walletIndex to default to wallets[0] when the specific wallet doesn't matter.
- This is a test utility — only relevant in launchTestNode() contractsConfigs.
When it happens
Trigger: In launchTestNode, passing a contractsConfigs entry with walletIndex set to a value >= the number of wallets in walletsConfig (or < 0), while walletsConfig.count (default 10) determines how many wallets are generated. For example, requesting walletIndex 10 when only 10 wallets exist (indices 0-9).
Common situations: Setting walletIndex beyond the default wallet count; reducing walletsConfig.count without updating walletIndex references; off-by-one errors assuming 1-indexed wallets (they are 0-indexed); copy-pasting a config that referenced a higher wallet index.
Related errors
- ACCOUNT_REQUIRED
- INVALID_CHUNK_SIZE_MULTIPLIER
- INVALID_INPUT_PARAMETERS
- MISSING_PROVIDER
- Contract not found!
AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12).
Data as JSON: /api/errors/4c2f65e4ebe89ef5.
Report an issue: GitHub.