FuelLabs/fuels-ts · error · FuelError
INVALID_TRANSACTION_INPUT
INVALID_TRANSACTION_INPUT
Error message
Contract input should be of type 'contract'.
What it means
Thrown by `getInputContract()` (transaction-summary/input.ts) when the input at the given `inputIndex` exists but its `type` is not `InputType.Contract`. The function is used during transaction summary assembly to resolve a contract input referenced by an output; if the slot holds a Coin or Message instead, the type contract is violated and decoding would be unsafe.
Source
Thrown at packages/account/src/providers/transaction-summary/input.ts:117
return undefined;
}
/** @hidden */
export function getInputContractFromIndex(
inputs: Input[],
inputIndex: number
): InputContract | undefined {
if (inputIndex == null) {
return undefined;
}
const contractInput = inputs?.[inputIndex];
if (!contractInput) {
return undefined;
}
if (contractInput.type !== InputType.Contract) {
throw new FuelError(
ErrorCode.INVALID_TRANSACTION_INPUT,
`Contract input should be of type 'contract'.`
);
}
return contractInput as InputContract;
}
/** @hidden */
export function getInputAccountAddress(input: Input) {
if (input.type === InputType.Coin) {
return input.owner.toString();
}
if (input.type === InputType.Message) {
return input.recipient.toString();
}
View on GitHub (pinned to b3f37c91ac)
Solutions
- Ensure contract outputs reference the correct `inputIndex` that points to a contract-type input.
- Do not reorder inputs after building outputs; rebuild the transaction request if input order changes.
- Validate input/output index consistency before submitting.
Example fix
// before (contract output points at a coin input slot)
request.inputs = [coinInput];
request.outputs = [{ type: OutputType.Contract, inputIndex: 0 }]; // wrong
// after
request.inputs = [contractInput, coinInput];
request.outputs = [{ type: OutputType.Contract, inputIndex: 0 }]; // points at contract Defensive patterns
Strategy: validation
Validate before calling
import { InputType } from '@fuel-ts/transactions';
function contractInputAt(inputs: any[], idx: number) {
const inp = inputs[idx];
return inp && inp.type === InputType.Contract ? inp : undefined;
} Type guard
function isInputContract(v: unknown): v is import('@fuel-ts/transactions').InputContract {
return typeof v === 'object' && v !== null && (v as any).type === InputType.Contract;
} Try / catch
null
Prevention
- Keep input ordering stable once contract outputs reference inputIndex.
- Rebuild the request rather than reordering inputs after outputs are set.
- Validate that contract outputs point at contract-type inputs.
When it happens
Trigger: Transaction summary assembly where a receipt/output references `inputIndex` pointing at a non-contract input. Typically reached internally from `getTransactionSummary` / `getTransactionSummaryFromRequest` when correlating contract outputs to their inputs.
Common situations: A malformed or corrupted transaction where input/output indices are inconsistent; a manually-constructed transaction with a contract output referencing a coin input index; decoding a transaction built by an incompatible tool that ordered inputs differently.
Related errors
- INVALID_TRANSACTION_INPUT
- UNSUPPORTED_TRANSACTION_TYPE
- INVALID_TRANSACTION_STATUS
- INVALID_RECEIPT_TYPE
- DECODE_ERROR
AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12).
Data as JSON: /api/errors/964129f6541a9642.
Report an issue: GitHub.