encodeLabelhash
Encodes a hash as an ENS encoded label
Loading...
Encodes a hash as an ENS encoded label
Encodes a hash as an ENS encoded label. This is the inverse of EncodedLabelToLabelhash.
import "github.com/ChefBingbong/viem-go/utils/ens"import "github.com/ChefBingbong/viem-go/utils/ens"
// Encode a labelhashencoded := ens.EncodeLabelhash("0x4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0")// "[4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0]"
// Works without 0x prefixencoded = ens.EncodeLabelhash("4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0")// "[4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0]"stringThe encoded label in the format [<64 hex chars>].
stringThe hash to encode. Should be 64 hex characters (with or without 0x prefix).
encoded := ens.EncodeLabelhash("0x4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0")// "[4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0]"Encoded labels are in the format:
[<64 hex characters>]
For example: [4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0]
0x prefix if presentEncodedLabelToLabelhash