Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package ens
import (
"strings"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
func Namehash(name string) common.Hash {
var (
h common.Hash
labels = strings.Split(name, ".")
)
for i := len(labels) - 1; i >= 0; i-- {
h = crypto.Keccak256Hash(
h.Bytes(),
crypto.Keccak256Hash([]byte(labels[i])).Bytes(),
)
}
return h
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment