{"record":{"id":"fa09f5649a02fd7c","repo":"FuelLabs/fuels-ts","slug":"unsupported-transaction-type-fa09f5","errorCode":"UNSUPPORTED_TRANSACTION_TYPE","errorMessage":"Unsupported transaction type: ${type}","messagePattern":"Unsupported transaction type: (.+?)","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/transactions/src/coders/transaction.ts","lineNumber":653,"sourceCode":"      }\n      case TransactionType.Upgrade: {\n        parts.push(\n          new TransactionUpgradeCoder().encode(value as Transaction<TransactionType.Upgrade>)\n        );\n        break;\n      }\n      case TransactionType.Upload: {\n        parts.push(\n          new TransactionUploadCoder().encode(value as Transaction<TransactionType.Upload>)\n        );\n        break;\n      }\n      case TransactionType.Blob: {\n        parts.push(new TransactionBlobCoder().encode(value as Transaction<TransactionType.Blob>));\n        break;\n      }\n      default: {\n        throw new FuelError(\n          ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,\n          `Unsupported transaction type: ${type}`\n        );\n      }\n    }\n\n    return concat(parts);\n  }\n\n  decode(data: Uint8Array, offset: number): [Transaction, number] {\n    let decoded;\n    let o = offset;\n\n    [decoded, o] = new NumberCoder('u8', { padToWordSize: true }).decode(data, o);\n    const type = decoded as TransactionType;\n\n    switch (type) {\n      case TransactionType.Script: {","sourceCodeStart":635,"sourceCodeEnd":671,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/transactions/src/coders/transaction.ts#L635-L671","documentation":"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.","triggerScenarios":"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].","commonSituations":"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.","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."],"exampleFix":"// before\nconst tx = { type: 9, ... };\n\n// after\nimport { TransactionType } from '@fuel-ts/transactions';\nconst tx = { type: TransactionType.Script, ... };","handlingStrategy":"type-guard","validationCode":"import { TransactionType } from '@fuel-ts/transactions';\n\nconst VALID_TX_TYPES = new Set([\n  TransactionType.Script, TransactionType.Create, TransactionType.Mint,\n  TransactionType.Upgrade, TransactionType.Upload, TransactionType.Blob,\n]);\nif (!VALID_TX_TYPES.has(tx.type as TransactionType)) {\n  throw new Error(`Unsupported transaction type: ${tx.type}`);\n}","typeGuard":"import { TransactionType } from '@fuel-ts/transactions';\nfunction isSupportedTransactionType(t: number): boolean {\n  return t >= TransactionType.Script && t <= TransactionType.Blob;\n}","tryCatchPattern":"try {\n  txCoder.encode(tx);\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {\n    // coerce tx.type to a supported TransactionType, or upgrade SDK\n  } else throw e;\n}","preventionTips":["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."],"tags":["transaction","encode","version-skew","typescript"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}