{"record":{"id":"b2ab68082dca74de","repo":"FuelLabs/fuels-ts","slug":"parse-failed-b2ab68","errorCode":"PARSE_FAILED","errorMessage":"Cannot generate EVM Address B256 from: ${b256}.","messagePattern":"Cannot generate EVM Address B256 from: (.+?)\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/address/src/utils.ts","lineNumber":101,"sourceCode":"/**\n * Takes a B256 address and clears the first 12 bytes, this is required for an EVM Address\n *\n * @param b256 - the address to clear\n * @returns b256 with first 12 bytes cleared\n *\n * @hidden\n */\nexport const toB256AddressEvm = (b256: B256Address): B256AddressEvm => {\n  try {\n    if (!isB256(b256)) {\n      throw new FuelError(FuelError.CODES.INVALID_B256_ADDRESS, `Invalid B256 Address: ${b256}.`);\n    }\n\n    const evmBytes = arrayify(b256).slice(12);\n    const paddedBytes = new Uint8Array(12).fill(0);\n    return hexlify(concat([paddedBytes, evmBytes])) as B256AddressEvm;\n  } catch (error) {\n    throw new FuelError(\n      FuelError.CODES.PARSE_FAILED,\n      `Cannot generate EVM Address B256 from: ${b256}.`\n    );\n  }\n};\n\n/**\n * Pads the first 12 bytes of an Evm address. This is useful for padding addresses returned from\n * the EVM to interact with the Sway EVM Address Type.\n *\n * @param address - Evm address to be padded\n * @returns Evm address padded to a b256 address\n *\n * @hidden\n */\nexport const padFirst12BytesOfEvmAddress = (address: string): B256AddressEvm => {\n  if (!isEvmAddress(address)) {\n    throw new FuelError(FuelError.CODES.INVALID_EVM_ADDRESS, 'Invalid EVM address format.');","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/address/src/utils.ts#L83-L119","documentation":"The catch-all in toB256AddressEvm() (packages/address/src/utils.ts:101). It wraps every error produced inside the function body — including the inner INVALID_B256_ADDRESS throw (error 161) and any failure from arrayify(), concat(), or hexlify() — and re-throws as PARSE_FAILED. This is the error callers actually observe when toB256AddressEvm fails, regardless of root cause.","triggerScenarios":"Calling toB256AddressEvm() with a string that is not a valid B256 address (wrong length, bad prefix, non-hex characters), or with a value that causes arrayify/concat/hexlify to throw (e.g. a non-string BytesLike that cannot be parsed).","commonSituations":"Interacting with EVM-compatible Sway contract types; converting a B256 address to its 12-byte-cleared EVM representation; passing an address obtained from an untrusted source without prior validation.","solutions":["Pre-validate the input with isB256() to guarantee 0x + 64 hex characters before calling.","Check the actual value in the error message ('Cannot generate EVM Address B256 from: <value>') to identify truncation or format corruption.","If the input originates from another SDK call, ensure that call returns a B256Address-typed string, not a checksum or EVM-format string."],"exampleFix":"// before\nconst evm = toB256AddressEvm(input);\n\n// after\nimport { isB256 } from '@fuel-ts/address';\nif (!isB256(input)) {\n  throw new Error(`Expected B256 address, got: ${input}`);\n}\nconst evm = toB256AddressEvm(input);","handlingStrategy":"type-guard","validationCode":"import { isB256 } from '@fuel-ts/address';\n\nif (!isB256(b256)) {\n  throw new Error(`Invalid B256 address: ${b256}. Must be 0x + 64 hex characters.`);\n}\nconst evm = toB256AddressEvm(b256);","typeGuard":"import { isB256 } from '@fuel-ts/address';\n\nfunction isB256Address(value: string): value is B256Address {\n  return value.length === 66 && /(0x)[0-9a-f]{64}$/i.test(value);\n}\n// Usage:\n// if (isB256Address(value)) toB256AddressEvm(value);","tryCatchPattern":"try {\n  const evm = toB256AddressEvm(b256);\n} catch (e) {\n  if (e instanceof FuelError && e.code === 'parse-failed') {\n    console.error('B256-to-EVM conversion failed for:', b256);\n    // re-throw with user-friendly message or fallback\n  }\n  throw e;\n}","preventionTips":["Pre-validate with isB256() to avoid the catch-all PARSE_FAILED wrapper.","Note that this catch-all masks the specific INVALID_B256_ADDRESS code — you cannot distinguish format errors from arrayify/hexlify errors.","Normalize all B256 addresses through Address or getRandomB256() to guarantee correct format."],"tags":["address","b256","evm","parse-error","catch-all"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}