{"record":{"id":"601f0ce61d7cb1c7","repo":"FuelLabs/fuels-ts","slug":"invalid-address","errorCode":"INVALID_ADDRESS","errorMessage":"Invalid address","messagePattern":"Invalid address","errorType":"validation","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/address/src/utils.ts","lineNumber":75,"sourceCode":"/**\n * Takes an indeterminate address type and returns an address\n *\n * @hidden\n */\nexport const addressify = (addressLike: AddressLike | ContractIdLike): Address => {\n  if (isAddress(addressLike)) {\n    return addressLike;\n  }\n\n  if ('address' in addressLike && isAddress(addressLike.address)) {\n    return addressLike.address;\n  }\n\n  if ('id' in addressLike && isAddress(addressLike.id)) {\n    return addressLike.id;\n  }\n\n  throw new FuelError(FuelError.CODES.INVALID_ADDRESS, 'Invalid address');\n};\n\n/**\n * @hidden\n */\nexport const getRandomB256 = () => hexlify(randomBytes(32));\n\n/**\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)) {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/address/src/utils.ts#L57-L93","documentation":"Thrown by the addressify() utility (packages/address/src/utils.ts:75) when the input cannot be resolved to an Address. The function accepts an Address instance (duck-typed by the presence of a 'b256Address' property), an object with an '.address' property that is itself an Address, or an object with an '.id' property that is an Address. If none of these three shapes match, the SDK cannot extract an address and throws INVALID_ADDRESS. This helper is used pervasively across the SDK wherever a dynamic AddressLike or ContractIdLike input must be normalized.","triggerScenarios":"Calling addressify() — or any SDK function that internally calls it — with a raw string, a number, a plain object without b256Address/address/id keys, or an object whose nested .address or .id value lacks the b256Address property (i.e. is not a real Address instance).","commonSituations":"Passing a contractId string where an Address or AddressLike object is required; passing a primitive or mis-typed value through an untyped boundary (e.g. from JSON or user input); passing a Contract that has been serialized/deserialized losing its Address identity; confusing which field a wrapper object exposes.","solutions":["Wrap the raw value in an Address instance before passing it: new Address(value) or Address.fromDynamicInput(value).","If you hold a Contract object, pass the object itself — it exposes an 'id' property — rather than contract.id (a string).","If you hold an Account or Wallet, pass the object itself — it exposes an 'address' property.","Check the callee's parameter type: it expects AddressLike | ContractIdLike, not a bare string."],"exampleFix":"// before\nconst params = [someRawHexString, amount];\ncontract.functions.mint(...params);\n\n// after\nconst params = [new Address(someRawHexString), amount];\ncontract.functions.mint(...params);","handlingStrategy":"type-guard","validationCode":"import { isAddress } from '@fuel-ts/address';\nimport { Address } from '@fuel-ts/address';\n\nfunction resolveAddress(input: unknown): Address {\n  if (input instanceof Address) return input;\n  if (typeof input === 'object' && input !== null) {\n    if ('address' in input && isAddress(input.address as object)) return input.address;\n    if ('id' in input && isAddress(input.id as object)) return input.id;\n  }\n  if (typeof input === 'string') return new Address(input);\n  throw new Error('Cannot resolve input to Address');\n}","typeGuard":"import { isAddress } from '@fuel-ts/address';\n\nfunction isAddressLike(value: unknown): value is Address {\n  if (isAddress(value as object)) return true;\n  if (typeof value !== 'object' || value === null) return false;\n  if ('address' in value && isAddress((value as any).address)) return true;\n  if ('id' in value && isAddress((value as any).id)) return true;\n  return false;\n}","tryCatchPattern":"try {\n  const addr = addressify(input);\n} catch (e) {\n  if (e.code === 'invalid-address') {\n    // input is not AddressLike or ContractIdLike; wrap or reject\n  }\n  throw e;\n}","preventionTips":["Always wrap raw strings in new Address() before passing to SDK functions that expect AddressLike.","Pass Contract objects directly (they have .id), not contract.id strings.","Pass Account/Wallet objects directly (they have .address).","Use TypeScript's type system: declare parameters as Address | Contract rather than string | any."],"tags":["address","input-validation","typescript","duck-typing"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}