encodedLabelToLabelhash
Converts an encoded label to a labelhash
Loading...
Converts an encoded label to a labelhash
Converts an encoded label (e.g., [abc123...]) to a labelhash. Returns empty string if the label is not a valid encoded labelhash.
import "github.com/ChefBingbong/viem-go/utils/ens"import "github.com/ChefBingbong/viem-go/utils/ens"
// Convert encoded label to labelhashhash := ens.EncodedLabelToLabelhash("[4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0]")// "0x4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0"
// Not an encoded labelhash = ens.EncodedLabelToLabelhash("eth")// ""stringThe labelhash as a hex string with 0x prefix, or empty string if the input is not a valid encoded label.
stringThe encoded label to convert. Must be in the format [<64 hex chars>].
hash := ens.EncodedLabelToLabelhash("[4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0]")// "0x4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0"
hash = ens.EncodedLabelToLabelhash("eth")// ""The function validates:
[ + 64 hex chars + ])[]Namehash and Labelhash to handle encoded labelsEncodeLabelhash