{"record":{"id":"fb40da8c03b15c74","repo":"FuelLabs/fuels-ts","slug":"decode-error-fb40da","errorCode":"DECODE_ERROR","errorMessage":"Invalid ${this.type} data size.","messagePattern":"Invalid (.+?) data size\\.","errorType":"error_code","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/abi-coder/src/encoding/coders/BigNumberCoder.ts","lineNumber":44,"sourceCode":"    if (typeof value === 'number' && value > Number.MAX_SAFE_INTEGER) {\n      throw new FuelError(\n        ErrorCode.ENCODE_ERROR,\n        `Invalid ${this.type} type - number value is too large. Number can only safely handle up to 53 bits.`\n      );\n    }\n\n    try {\n      bytes = toBytes(value, this.encodedLength);\n    } catch (error) {\n      throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.type}.`);\n    }\n\n    return bytes;\n  }\n\n  decode(data: Uint8Array, offset: number): [BN, number] {\n    if (data.length < this.encodedLength) {\n      throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid ${this.type} data size.`);\n    }\n\n    let bytes = data.slice(offset, offset + this.encodedLength);\n    bytes = bytes.slice(0, this.encodedLength);\n\n    if (bytes.length !== this.encodedLength) {\n      throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid ${this.type} byte data size.`);\n    }\n\n    return [bn(bytes), offset + this.encodedLength];\n  }\n}\n","sourceCodeStart":26,"sourceCodeEnd":57,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/abi-coder/src/encoding/coders/BigNumberCoder.ts#L26-L57","documentation":"Thrown by BigNumberCoder.decode at the top guard: data.length < this.encodedLength (8 for u64, 32 for u256). this.type is the baseType, so the message reads \"Invalid u64 data size.\" (or u256). The buffer is too short to contain one encoded big number.","triggerScenarios":"Calling bignum.decode(data, offset) with data shorter than the type's encoded length, e.g. decoding an 8-byte field from a 4-byte slice, or handing decode a truncated receipt payload.","commonSituations":"Truncated log/receipt data from the provider; wrong coder chosen for the bytes; offset advanced past the available data; manual slicing that dropped bytes.","solutions":["Verify the buffer is the complete, untruncated encoded payload.","Ensure data.length >= this.encodedLength (8 for u64, 32 for u256) before decode.","Use AbiCoder/Interface decoding so field boundaries are tracked automatically.","Re-fetch the data if the provider truncated it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const need = bigNumberCoder.encodedLength // 8 or 32\nif (data.length < need) throw new Error(`need ${need} bytes, got ${data.length}`)\nbigNumberCoder.decode(data, offset)","typeGuard":"const canDecodeBigNumber = (data: Uint8Array, len: number) => data.length >= len","tryCatchPattern":"try { bigNumberCoder.decode(data, offset) }\ncatch (e) { if ((e as FuelError).code === ErrorCode.DECODE_ERROR) { /* re-fetch full payload */ } throw e }","preventionTips":["Verify the full encoded payload length before manual decode.","Use the high-level decoder to avoid length mistakes.","Treat short buffers as provider truncation."],"tags":["abi-coder","decoding","u64","u256","data-length"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}