{"record":{"id":"5ec9b01520aa867b","repo":"FuelLabs/fuels-ts","slug":"decode-error-5ec9b0","errorCode":"DECODE_ERROR","errorMessage":"Invalid TxPointer scalar string length ${value.length}. It must have length 12.","messagePattern":"Invalid TxPointer scalar string length (.+?)\\. It must have length 12\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/transactions/src/coders/tx-pointer.ts","lineNumber":26,"sourceCode":"  /** Transaction index (u16) */\n  txIndex: number;\n};\n\nexport class TxPointerCoder extends StructCoder<{\n  blockHeight: NumberCoder;\n  txIndex: NumberCoder;\n}> {\n  constructor() {\n    super('TxPointer', {\n      blockHeight: new NumberCoder('u32', { padToWordSize: true }),\n      txIndex: new NumberCoder('u16', { padToWordSize: true }),\n    });\n  }\n\n  public static decodeFromGqlScalar(value: string) {\n    // taken from https://github.com/FuelLabs/fuel-vm/blob/7366db6955589cb3444c9b2bb46e45c8539f19f5/fuel-tx/src/tx_pointer.rs#L87\n    if (value.length !== 12) {\n      throw new FuelError(\n        ErrorCode.DECODE_ERROR,\n        `Invalid TxPointer scalar string length ${value.length}. It must have length 12.`\n      );\n    }\n    const [blockHeight, txIndex] = [value.substring(0, 8), value.substring(8)];\n    return {\n      blockHeight: parseInt(blockHeight, 16),\n      txIndex: parseInt(txIndex, 16),\n    };\n  }\n}\n","sourceCodeStart":8,"sourceCodeEnd":38,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/transactions/src/coders/tx-pointer.ts#L8-L38","documentation":"Thrown by TxPointerCoder.decodeFromGqlScalar when the GraphQL scalar string representing a transaction pointer is not exactly 12 characters long. The decoder expects an 8-char hex blockHeight segment followed by a 4-char hex txIndex segment (matching fuel-vm's TxPointer parsing). Any other length is treated as malformed input and rejected before parsing begins.","triggerScenarios":"Calling TxPointerCoder.decodeFromGqlScalar(value) where value is a string of length != 12. This happens when the GraphQL response for a transaction's txPointer field is truncated, padded, prefixed with '0x', or null/empty. The check `value.length !== 12` runs before any substring parsing.","commonSituations":"A fuel-core node returns a txPointer scalar in an unexpected format (e.g. with '0x' prefix, or zero-padded to a different width). Upgrading fuel-core changes the scalar serialization. Mock/stub GraphQL responses in tests that hardcode a wrong-length txPointer string. Manually constructing a TxPointer from a hex string without stripping prefixes.","solutions":["Inspect the exact value passed to decodeFromGqlScalar; strip any '0x' prefix before calling it.","Verify the fuel-core node version matches the SDK's expected TxPointer format (8 hex chars blockHeight + 4 hex chars txIndex).","If consuming GraphQL data, check the schema/response for the txPointer field and confirm it is a 12-char hex string.","Add a length/format precondition in your own code: if (typeof v === 'string' && /^[0-9a-f]{12}$/i.test(v)) before decoding."],"exampleFix":"// before\nTxPointerCoder.decodeFromGqlScalar(rawTxPointer); // rawTxPointer = '0x000000010002'\n\n// after\nconst clean = rawTxPointer.startsWith('0x') ? rawTxPointer.slice(2) : rawTxPointer;\nTxPointerCoder.decodeFromGqlScalar(clean);","handlingStrategy":"validation","validationCode":"function isTxPointerScalar(v: unknown): v is string {\n  return typeof v === 'string' && /^[0-9a-fA-F]{12}$/.test(v);\n}\n// before decoding:\nif (!isTxPointerScalar(raw)) throw new Error(`bad txPointer scalar: ${String(raw)}`);\nTxPointerCoder.decodeFromGqlScalar(raw);","typeGuard":"const isTxPointerScalar = (v: unknown): v is string =>\n  typeof v === 'string' && v.length === 12 && /^[0-9a-fA-F]{12}$/.test(v);","tryCatchPattern":"try {\n  const { blockHeight, txIndex } = TxPointerCoder.decodeFromGqlScalar(clean);\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.DECODE_ERROR) {\n    // handle malformed scalar\n  }\n  throw e;\n}","preventionTips":["Always strip a leading '0x' before passing a scalar to decodeFromGqlScalar.","Validate length and hex charset with a regex before decoding.","Pin the fuel-core node version to one whose TxPointer format matches the SDK."],"tags":["decode","tx-pointer","graphql","validation"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}