Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
911fad0
chore: upgrade to ENSv2 (Universal Resolver)
Dhaiwat10 May 5, 2026
e68d7b4
test: address review feedback on test fixtures
May 7, 2026
46e674e
fix(dnsencode): enforce RFC 1035 label and total-name limits
yashgo0018 May 26, 2026
e2afb3e
fix(dnsencode): drop total-name length guard per ENSIP-10
yashgo0018 May 26, 2026
0a6a086
fix(ccipread): bound hops correctly, cap body, gate JSON on Content-Type
yashgo0018 May 26, 2026
3f49037
refactor(urerrors): rename ResolverErrorError, cover remaining decoders
yashgo0018 May 26, 2026
7fcbe71
test(universalresolver): skip live-RPC tests under -short
yashgo0018 May 26, 2026
22dfa44
feat: add ResolveContext / ReverseResolveContext, honor ctx.Deadline
yashgo0018 May 26, 2026
3a12310
feat(universalresolver): chain-ID guardrail on default constructor
yashgo0018 May 26, 2026
0830688
docs: flag that Resolver.Address and Name.Address skip the UR
yashgo0018 May 26, 2026
9e63e9f
fix(ccipread): SSRF defenses + typed GatewayHTTPError
yashgo0018 May 26, 2026
5544794
fix: accept []byte from ErrorData() in revert decoders
yashgo0018 May 26, 2026
da238e2
chore: tighten ABI type checks and drop dead code
yashgo0018 May 26, 2026
b42e4a8
fix(universalresolver): include Holesky in known UR chain list
yashgo0018 May 27, 2026
88946cd
Adjust DNS label length tests to 63-byte cap
yashgo0018 Jun 20, 2026
4997277
Add NewUniversalResolverContext and propagate ctx
yashgo0018 Jun 20, 2026
78498de
Update Universal Resolver ABI and remove unused Go bindings
yashgo0018 Jul 6, 2026
aa48e03
Refactor for a V4 alpha.
Bez625 Jul 3, 2026
1d5f74d
Add mainnetClient function for consistent Ethereum mainnet RPC connec…
yashgo0018 Jul 31, 2026
3939917
feat(normalize): replace IDNA normaliser with ENSIP-15 (adraffy/go-en…
yashgo0018 May 27, 2026
49ac9bb
Update README.md for v4 release:
yashgo0018 Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ coverage.html

# Local TODO
TODO.md

# IntelliJ + friends.
.idea/
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

[![Tag](https://img.shields.io/github/tag/wealdtech/go-ens.svg)](https://github.com/wealdtech/go-ens/releases/)
[![License](https://img.shields.io/github/license/wealdtech/go-ens.svg)](LICENSE)
[![GoDoc](https://godoc.org/github.com/wealdtech/go-ens?status.svg)](https://godoc.org/github.com/wealdtech/go-ens)
[![GoDoc](https://pkg.go.dev/badge/github.com/wealdtech/go-ens/v4.svg)](https://pkg.go.dev/github.com/wealdtech/go-ens/v4)
[![Travis CI](https://img.shields.io/travis/wealdtech/go-ens.svg)](https://travis-ci.org/wealdtech/go-ens)
[![codecov.io](https://img.shields.io/codecov/c/github/wealdtech/go-ens.svg)](https://codecov.io/github/wealdtech/go-ens)
[![Go Report Card](https://goreportcard.com/badge/github.com/wealdtech/go-ens)](https://goreportcard.com/report/github.com/wealdtech/go-ens)

Go module to simplify interacting with the [Ethereum Name Service](https://ens.domains/) contracts.

v4 resolves names through the ENS [Universal Resolver](https://docs.ens.domains/web/ensv2-readiness/), so ENSIP-10 wildcards and ERC-3668 CCIP-Read work out of the box. Callers that need the previous registry-walking behaviour should stay on `github.com/wealdtech/go-ens/v3`.


## Table of Contents

Expand All @@ -23,7 +25,7 @@ Go module to simplify interacting with the [Ethereum Name Service](https://ens.d
`go-ens` is a standard Go module which can be installed with:

```sh
go get github.com/wealdtech/go-ens/v3
go get github.com/wealdtech/go-ens/v4
```

## Usage
Expand All @@ -35,21 +37,21 @@ go get github.com/wealdtech/go-ens/v3
The most commonly-used feature of ENS is resolution: converting an ENS name to an Ethereum address. `go-ens` provides a simple call to allow this:

```go
address, err := ens.Resolve(client, domain)
address, err := ens.Resolve(ctx, client, domain)
```

where `client` is a connection to an Ethereum client and `domain` is the fully-qualified name you wish to resolve (e.g. `foo.mydomain.eth`) (full examples for using this are given in the [Example](#Example) section below).
where `ctx` is a `context.Context` (honoured for cancellation and deadlines through any CCIP-Read hops), `client` is a connection to an Ethereum client, and `domain` is the fully-qualified name you wish to resolve (e.g. `foo.mydomain.eth`) (full examples for using this are given in the [Example](#Example) section below).

The reverse process, converting an address to an ENS name, is just as simple:

```go
domain, err := ens.ReverseResolve(client, address)
domain, err := ens.ReverseResolve(ctx, client, address)
```

Note that if the address does not have a reverse resolution this will return "". If you just want a string version of an address for on-screen display then you can use `ens.Format()`, for example:
If the address has no primary name set this returns an error (`"no resolution"`). If you just want a string version of an address for on-screen display then you can use `ens.Format()`, for example:

```go
fmt.Printf("The address is %s\n", ens.Format(client, address))
fmt.Printf("The address is %s\n", ens.Format(ctx, client, address))
```

This will carry out reverse resolution of the address and print the name if present; if not it will print a formatted version of the address.
Expand All @@ -70,7 +72,7 @@ Addresses can be set and obtained using the address functions, for example to ge

```go
COIN_TYPE_ETHEREUM := uint64(60)
address, err := name.Address(COIN_TYPE_ETHEREUM)
address, err := name.Address(ctx, COIN_TYPE_ETHEREUM)
```

ENS supports addresses for multiple coin types; values of coin types can be found at https://github.com/satoshilabs/slips/blob/master/slip-0044.md
Expand All @@ -90,13 +92,16 @@ Because subdomains have their own registrars they do not work with the `Name` in
package main

import (
"context"
"fmt"

"github.com/ethereum/go-ethereum/ethclient"
ens "github.com/wealdtech/go-ens/v3"
ens "github.com/wealdtech/go-ens/v4"
)

func main() {
ctx := context.Background()

// Replace SECRET with your own access token for this example to work.
client, err := ethclient.Dial("https://mainnet.infura.io/v3/SECRET")
if err != nil {
Expand All @@ -105,19 +110,16 @@ func main() {

// Resolve a name to an address.
domain := "ethereum.eth"
address, err := ens.Resolve(client, domain)
address, err := ens.Resolve(ctx, client, domain)
if err != nil {
panic(err)
}
fmt.Printf("Address of %s is %s\n", domain, address.Hex())

// Reverse resolve an address to a name.
reverse, err := ens.ReverseResolve(client, address)
reverse, err := ens.ReverseResolve(ctx, client, address)
if err != nil {
panic(err)
}
if reverse == "" {
fmt.Printf("%s has no reverse lookup\n", address.Hex())
fmt.Printf("%s has no reverse lookup: %v\n", address.Hex(), err)
} else {
fmt.Printf("Name of %s is %s\n", address.Hex(), reverse)
}
Expand Down
2 changes: 1 addition & 1 deletion auctionregistrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/wealdtech/go-ens/v3/contracts/auctionregistrar"
"github.com/wealdtech/go-ens/v4/contracts/auctionregistrar"
)

// AuctionRegistrar is the structure for the auction registrar contract.
Expand Down
2 changes: 1 addition & 1 deletion baseregistrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/wealdtech/go-ens/v3/contracts/baseregistrar"
"github.com/wealdtech/go-ens/v4/contracts/baseregistrar"
"golang.org/x/crypto/sha3"
)

Expand Down
Loading