Skip to main content

bridge/functions/stripHexPrefix.md

stripHexPrefix(hex): string

Removes "0x" prefix from Ethereum address hex values

Consolidates 13 scattered instances of manual 0x removal patterns:

  • .replace('0x', '')
  • .slice(2)
  • .substring(2) with startsWith check

Parameters​

ParameterTypeDescription
hexstringHex value potentially with 0x prefix

Returns​

string

Hex value without 0x prefix

Example​

stripHexPrefix('0x123abc') // '123abc'
stripHexPrefix('123abc') // '123abc'