FuelLabs/fuels-ts · error · FuelError
UNSUPPORTED_TRANSACTION_TYPE
UNSUPPORTED_TRANSACTION_TYPE
Error message
Unsupported transaction type: ${type} What it means
Thrown by TransactionCoder.encode() when transaction.type is not one of the supported TransactionType values (Script=0, Create=1, Mint=2, Upgrade=3, Upload=4, Blob=5). The encode switch has cases for all six; reaching default means type is out of range (e.g. 6+ or negative) or not a number.
Source
Thrown at packages/transactions/src/coders/transaction.ts:653
}
case TransactionType.Upgrade: {
parts.push(
new TransactionUpgradeCoder().encode(value as Transaction<TransactionType.Upgrade>)
);
break;
}
case TransactionType.Upload: {
parts.push(
new TransactionUploadCoder().encode(value as Transaction<TransactionType.Upload>)
);
break;
}
case TransactionType.Blob: {
parts.push(new TransactionBlobCoder().encode(value as Transaction<TransactionType.Blob>));
break;
}
default: {
throw new FuelError(
ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
`Unsupported transaction type: ${type}`
);
}
}
return concat(parts);
}
decode(data: Uint8Array, offset: number): [Transaction, number] {
let decoded;
let o = offset;
[decoded, o] = new NumberCoder('u8', { padToWordSize: true }).decode(data, o);
const type = decoded as TransactionType;
switch (type) {
case TransactionType.Script: {View on GitHub (pinned to b3f37c91ac)
Solutions
- Use the TransactionType enum when constructing transactions.
- Validate transaction.type is within [0,5] before encoding.
- Upgrade @fuel-ts/transactions to match the node's supported transaction variants.
Example fix
// before
const tx = { type: 9, ... };
// after
import { TransactionType } from '@fuel-ts/transactions';
const tx = { type: TransactionType.Script, ... }; Defensive patterns
Strategy: type-guard
Validate before calling
import { TransactionType } from '@fuel-ts/transactions';
const VALID_TX_TYPES = new Set([
TransactionType.Script, TransactionType.Create, TransactionType.Mint,
TransactionType.Upgrade, TransactionType.Upload, TransactionType.Blob,
]);
if (!VALID_TX_TYPES.has(tx.type as TransactionType)) {
throw new Error(`Unsupported transaction type: ${tx.type}`);
} Type guard
import { TransactionType } from '@fuel-ts/transactions';
function isSupportedTransactionType(t: number): boolean {
return t >= TransactionType.Script && t <= TransactionType.Blob;
} Try / catch
try {
txCoder.encode(tx);
} catch (e) {
if (e instanceof FuelError && e.code === ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
// coerce tx.type to a supported TransactionType, or upgrade SDK
} else throw e;
} Prevention
- Set transaction.type via the TransactionType enum, not raw numbers.
- Ensure type is defined and within the supported range before encoding.
- Keep @fuel-ts/* versions aligned with the node for new transaction variants.
When it happens
Trigger: Encoding a transaction object whose type field is set to an invalid or future value; constructing a transaction from unvalidated data; assigning a raw number outside [0,5].
Common situations: Hand-building a transaction object without the enum; a new transaction variant added by a newer Fuel-Core that the installed SDK does not yet support; type field left undefined.
Related errors
- INVALID_TRANSACTION_INPUT
- INVALID_TRANSACTION_OUTPUT
- INVALID_POLICY_TYPE
- INVALID_TRANSACTION_INPUT
- INVALID_TRANSACTION_INPUT
AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12).
Data as JSON: /api/errors/fa09f5649a02fd7c.
Report an issue: GitHub.