{"record":{"id":"9252fdee7f07db62","repo":"FuelLabs/fuels-ts","slug":"invalid-b256-address","errorCode":"INVALID_B256_ADDRESS","errorMessage":"Invalid B256 Address: ${b256Address}.","messagePattern":"Invalid B256 Address: (.+?)\\.","errorType":"validation","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/address/src/address.ts","lineNumber":155,"sourceCode":"   *\n   * @deprecated Use `new Address` instead\n   */\n  static fromPublicKey(publicKey: string): Address {\n    const b256Address = fromPublicKeyToB256(publicKey);\n    return new Address(b256Address);\n  }\n\n  /**\n   * Takes a B256 Address and creates an `Address`\n   *\n   * @param b256Address - A b256 hash\n   * @returns A new `Address` instance\n   *\n   * @deprecated Use `new Address` instead\n   */\n  static fromB256(b256Address: string): Address {\n    if (!isB256(b256Address)) {\n      throw new FuelError(\n        FuelError.CODES.INVALID_B256_ADDRESS,\n        `Invalid B256 Address: ${b256Address}.`\n      );\n    }\n\n    return new Address(b256Address);\n  }\n\n  /**\n   * Creates an `Address` with a randomized `b256Address` property\n   *\n   * @returns A new `Address` instance\n   */\n  static fromRandom(): Address {\n    return new Address(getRandomB256());\n  }\n\n  /**","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/address/src/address.ts#L137-L173","documentation":"Thrown by the deprecated Address.fromB256(b256Address) static factory when isB256(b256Address) returns false. A valid B256 address is a 0x-prefixed 64-hex-char string (66 chars total). Any other format, length, or non-hex content is rejected. New code should use `new Address(b256Address)` which performs equivalent validation internally.","triggerScenarios":"Calling Address.fromB256() with a string that is not 66 characters, not 0x-prefixed, contains non-hex characters, or is undefined/null coerced to a string.","commonSituations":"Address copied without the 0x prefix; trailing newline or whitespace; an EVM-style 0x-prefixed 40-hex-char address passed by mistake; a public key (128 hex chars) passed instead; a bech32 or other-format address from a different chain.","solutions":["Supply a 0x-prefixed 64-hex-character B256 address.","Trim whitespace/newlines from address strings read from files or user input.","Prefer `new Address(input)` over the deprecated fromB256 — it accepts B256, public key, or EVM address.","If you have an EVM address, use new Address(evmAddress) instead."],"exampleFix":"// before\nconst a = Address.fromB256(rawLineFromFile); // has trailing newline\n// after\nconst a = new Address(rawLineFromFile.trim());","handlingStrategy":"validation","validationCode":"import { isB256 } from '@fuel-ts/address/utils';\nif (!isB256(maybeB256)) throw new Error('Not a B256 address');\nconst addr = new Address(maybeB256);","typeGuard":"import { isB256 } from '@fuel-ts/address/utils';\nconst isB256Address = (s: unknown): s is string => typeof s === 'string' && isB256(s);","tryCatchPattern":null,"preventionTips":["Prefer `new Address(input)` over the deprecated fromB256.","Trim whitespace from address strings sourced from files or user input.","Validate format with isB256() before constructing."],"tags":["address","validation","b256","deprecated"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}