GithubHelp home page GithubHelp logo

go-ens's Introduction

wealdtech

Core for Weald Technology Java utilities and libraries.

License

Copyright 2012 Weald Technology Trading Limited.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

[http://www.apache.org/licenses/LICENSE-2.0]http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

go-ens's People

Contributors

0xcharchar avatar hewigovens avatar mcdee avatar peterjan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go-ens's Issues

Reverse resolution is returning invalid records

According to ENS documentation, the reverse record of an address is only valid if the forward resolution of that ENS name matches the address.

Current behavior:
The library is showing invalid ENS names as the result of reverse resolution calls.

Expected behavior:
The library should follow the ENS spec and validate if the reverse record is valid.

Feature Request: Support for non-IPFS content field values, including Skynet skylinks

Since ENS now officially supports various protocols for a domain's content record, I'd propose extending the functionality of go-ens to support additional protocols.

Specifically, I'm interested in sia:// values as we work with a project using go-ens to better support Skynet.

Would love feedback on the idea and suggestions on where to start with a PR.

found package github.com/btcsuite/btcd/chaincfg/chainhash in multiple modules

when I update deps:

go get -u ./...

returns:

go get -u ./...
go: upgraded github.com/btcsuite/btcd v0.22.0-beta => v0.22.1
go: added github.com/btcsuite/btcd/btcec/v2 v2.2.0
go: added github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1
go: upgraded github.com/ethereum/go-ethereum v1.10.15 => v1.10.17
go: upgraded github.com/gorilla/websocket v1.4.2 => v1.5.0
go: upgraded github.com/ipfs/go-cid v0.1.0 => v0.2.0
go: upgraded github.com/klauspost/cpuid/v2 v2.0.11 => v2.0.12
go: upgraded github.com/tklauser/go-sysconf v0.3.9 => v0.3.10
go: upgraded github.com/tklauser/numcpus v0.4.0 => v0.5.0
go: upgraded golang.org/x/crypto v0.0.0-20220213190939-1e6e3497d506 => v0.0.0-20220518034528-6f7dac969898
go: upgraded golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd => v0.0.0-20220520000938-2e3eb7b945c2
go: upgraded golang.org/x/sys v0.0.0-20220209214540-3681064d5158 => v0.0.0-20220520151302-bc2c85ada10a

but, when I try to run go mod tidy:

returns:

ens imports
        github.com/ethereum/go-ethereum/ethclient imports
        github.com/ethereum/go-ethereum/core/types imports
        github.com/ethereum/go-ethereum/crypto imports
        github.com/btcsuite/btcd/btcec/v2/ecdsa tested by
        github.com/btcsuite/btcd/btcec/v2/ecdsa.test imports
        github.com/btcsuite/btcd/chaincfg/chainhash: ambiguous import: found package github.com/btcsuite/btcd/chaincfg/chainhash in multiple modules:
        github.com/btcsuite/btcd v0.22.0-beta (/Users/jxlwqq/go/pkg/mod/github.com/btcsuite/[email protected]/chaincfg/chainhash)
        github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 (/Users/jxlwqq/go/pkg/mod/github.com/btcsuite/btcd/chaincfg/[email protected])

Incorrect records returned for reverse record lookup

I'm seeing the same ENS name have multiple addresses respond to its reverse record. I've attached a demo program:

package main

import (
	"fmt"

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

func main() {
	client, err := ethclient.Dial("https://mainnet.infura.io/v3/")
	if err != nil {
		panic(err)
	}

	start := common.HexToAddress("0xb9354777fd3019df43fa36a85e76ee3fe2f8bc35")
	reverse, err := ens.ReverseResolve(client, start)
	if err != nil {
		panic(err)
	}
	if reverse == "" {
		fmt.Printf("%s has no reverse lookup\n", start.Hex())
	} else {
		fmt.Printf("Name of %s is %s\n", start.Hex(), reverse)
	}

	confirm := common.HexToAddress("0x6924686B3DCD04Ae8ef91a3fEccC262d020F519D")
	reverse, err = ens.ReverseResolve(client, confirm)
	if err != nil {
		panic(err)
	}
	if reverse == "" {
		fmt.Printf("%s has no reverse lookup\n", confirm.Hex())
	} else {
		fmt.Printf("Name of %s is %s\n", confirm.Hex(), reverse)
	}

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

When I run this program, I get the following output:

$ go run main.go
Name of 0xb9354777Fd3019DF43fA36a85E76eE3fE2F8bc35 is itzler.eth
Name of 0x6924686B3DCD04Ae8ef91a3fEccC262d020F519D is itzler.eth
Address of itzler.eth is 0x6924686B3DCD04Ae8ef91a3fEccC262d020F519D

Unless it's possible for the same reverse record to be associated with more than one address, I think there may be some bug here. Happy to help debug in any other way! I tried different RPC URLs from different providers and got the same results.

newly registered domain names does not resolve

A newly registered domain name that was registered on 05-03-2020 on ENS does not reverse resolve.

Example

ens.ReverseResolve with robdefeo.eth resolves to 0x74dbac8dbca500185d4dc44679a451df1d9ef710 however 0x74dbac8dbca500185d4dc44679a451df1d9ef710 does not reverse resolve using v3.3.0

Proposal: Define Error Variables

I’d like to allow library users to distinguish user caused errors and library or rpc caused errors.
This allows for better error handling by the user.

For example, in go-sql-driver/mysql, errors are defined by variables.
https://github.com/go-sql-driver/mysql/blob/ad9fa14acdcf7d0533e7fbe58728f3d216213ade/errors.go#L18-L31

In addition, complex ones are expressed by defining dedicated types.
https://github.com/go-sql-driver/mysql/blob/ad9fa14acdcf7d0533e7fbe58728f3d216213ade/errors.go#L57-L62

go get errors

When doing go get github.com/wealdtech/go-ens I get the following errors. Any ideas how to solve this?

I have go version go1.17.8 darwin/arm64

go: downloading github.com/wealdtech/go-ens v1.0.0
go: downloading github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9
go: downloading github.com/deckarep/golang-set v1.7.1
# github.com/wealdtech/go-ens/contracts/reverseregistrar
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseregistrar/reverseregistrar.go:23:6: undefined: abi.U256
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseregistrar/reverseregistrar.go:142:88: cannot use result (type interface {}) as type *[]interface {} in argument to _ReverseRegistrarContract.Contract.ReverseRegistrarContractCaller.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseregistrar/reverseregistrar.go:161:57: cannot use result (type interface {}) as type *[]interface {} in argument to _ReverseRegistrarContract.Contract.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseregistrar/reverseregistrar.go:183:48: cannot use out (type *common.Address) as type *[]interface {} in argument to _ReverseRegistrarContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseregistrar/reverseregistrar.go:209:48: cannot use out (type *common.Address) as type *[]interface {} in argument to _ReverseRegistrarContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseregistrar/reverseregistrar.go:235:48: cannot use out (type *[32]byte) as type *[]interface {} in argument to _ReverseRegistrarContract.contract.Call
# github.com/wealdtech/go-ens/contracts/auctionregistrar
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/auctionregistrar/auctionregistrar.go:23:6: undefined: abi.U256
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/auctionregistrar/auctionregistrar.go:142:88: cannot use result (type interface {}) as type *[]interface {} in argument to _AuctionRegistrarContract.Contract.AuctionRegistrarContractCaller.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/auctionregistrar/auctionregistrar.go:161:57: cannot use result (type interface {}) as type *[]interface {} in argument to _AuctionRegistrarContract.Contract.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/auctionregistrar/auctionregistrar.go:183:48: cannot use out (type *common.Address) as type *[]interface {} in argument to _AuctionRegistrarContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/auctionregistrar/auctionregistrar.go:245:48: cannot use out (type **big.Int) as type *[]interface {} in argument to _AuctionRegistrarContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/auctionregistrar/auctionregistrar.go:271:48: cannot use out (type *bool) as type *[]interface {} in argument to _AuctionRegistrarContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/auctionregistrar/auctionregistrar.go:297:48: cannot use out (type *uint32) as type *[]interface {} in argument to _AuctionRegistrarContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/auctionregistrar/auctionregistrar.go:323:48: cannot use out (type **big.Int) as type *[]interface {} in argument to _AuctionRegistrarContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/auctionregistrar/auctionregistrar.go:349:48: cannot use out (type *[32]byte) as type *[]interface {} in argument to _AuctionRegistrarContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/auctionregistrar/auctionregistrar.go:375:48: cannot use out (type *common.Address) as type *[]interface {} in argument to _AuctionRegistrarContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/auctionregistrar/auctionregistrar.go:375:48: too many errors
# github.com/wealdtech/go-ens/contracts/registry
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/registry/registry.go:23:6: undefined: abi.U256
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/registry/registry.go:142:72: cannot use result (type interface {}) as type *[]interface {} in argument to _RegistryContract.Contract.RegistryContractCaller.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/registry/registry.go:161:49: cannot use result (type interface {}) as type *[]interface {} in argument to _RegistryContract.Contract.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/registry/registry.go:183:40: cannot use out (type *common.Address) as type *[]interface {} in argument to _RegistryContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/registry/registry.go:209:40: cannot use out (type *common.Address) as type *[]interface {} in argument to _RegistryContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/registry/registry.go:235:40: cannot use out (type *uint64) as type *[]interface {} in argument to _RegistryContract.contract.Call
# github.com/wealdtech/go-ens/contracts/resolver
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/resolver/resolver.go:23:6: undefined: abi.U256
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/resolver/resolver.go:142:72: cannot use result (type interface {}) as type *[]interface {} in argument to _ResolverContract.Contract.ResolverContractCaller.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/resolver/resolver.go:161:49: cannot use result (type interface {}) as type *[]interface {} in argument to _ResolverContract.Contract.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/resolver/resolver.go:213:40: cannot use out (type *common.Address) as type *[]interface {} in argument to _ResolverContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/resolver/resolver.go:239:40: cannot use out (type *[]byte) as type *[]interface {} in argument to _ResolverContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/resolver/resolver.go:265:40: cannot use out (type *string) as type *[]interface {} in argument to _ResolverContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/resolver/resolver.go:295:40: cannot use out (type *struct { X [32]byte; Y [32]byte }) as type *[]interface {} in argument to _ResolverContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/resolver/resolver.go:327:40: cannot use out (type *bool) as type *[]interface {} in argument to _ResolverContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/resolver/resolver.go:353:40: cannot use out (type *string) as type *[]interface {} in argument to _ResolverContract.contract.Call
# github.com/wealdtech/go-ens/contracts/reverseresolver
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseresolver/reverseresolver.go:23:6: undefined: abi.U256
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseresolver/reverseresolver.go:142:70: cannot use result (type interface {}) as type *[]interface {} in argument to _ReverseResolver.Contract.ReverseResolverCaller.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseresolver/reverseresolver.go:161:48: cannot use result (type interface {}) as type *[]interface {} in argument to _ReverseResolver.Contract.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseresolver/reverseresolver.go:183:39: cannot use out (type *common.Address) as type *[]interface {} in argument to _ReverseResolver.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseresolver/reverseresolver.go:209:39: cannot use out (type *string) as type *[]interface {} in argument to _ReverseResolver.contract.Call
# github.com/wealdtech/go-ens/contracts/deed
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/deed/deed.go:23:6: undefined: abi.U256
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/deed/deed.go:142:64: cannot use result (type interface {}) as type *[]interface {} in argument to _DeedContract.Contract.DeedContractCaller.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/deed/deed.go:161:45: cannot use result (type interface {}) as type *[]interface {} in argument to _DeedContract.Contract.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/deed/deed.go:183:36: cannot use out (type **big.Int) as type *[]interface {} in argument to _DeedContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/deed/deed.go:209:36: cannot use out (type *common.Address) as type *[]interface {} in argument to _DeedContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/deed/deed.go:235:36: cannot use out (type *common.Address) as type *[]interface {} in argument to _DeedContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/deed/deed.go:261:36: cannot use out (type *common.Address) as type *[]interface {} in argument to _DeedContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/deed/deed.go:287:36: cannot use out (type **big.Int) as type *[]interface {} in argument to _DeedContract.contract.Call
# github.com/wealdtech/go-ens/util
../../go/pkg/mod/github.com/wealdtech/[email protected]/util/signer.go:31:11: cannot use func literal (type func(types.Signer, common.Address, *types.Transaction) (*types.Transaction, error)) as type bind.SignerFn in assignment
../../go/pkg/mod/github.com/wealdtech/[email protected]/util/signer.go:44:11: cannot use func literal (type func(types.Signer, common.Address, *types.Transaction) (*types.Transaction, error)) as type bind.SignerFn in assignment
# github.com/wealdtech/go-ens/contracts/dnsresolver
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/dnsresolver/dnsresolver.go:23:6: undefined: abi.U256
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/dnsresolver/dnsresolver.go:142:78: cannot use result (type interface {}) as type *[]interface {} in argument to _DNSResolverContract.Contract.DNSResolverContractCaller.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/dnsresolver/dnsresolver.go:161:52: cannot use result (type interface {}) as type *[]interface {} in argument to _DNSResolverContract.Contract.contract.Call: need type assertion
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/dnsresolver/dnsresolver.go:187:43: cannot use out (type *struct { ContentType *big.Int; Data []byte }) as type *[]interface {} in argument to _DNSResolverContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/dnsresolver/dnsresolver.go:219:43: cannot use out (type *common.Address) as type *[]interface {} in argument to _DNSResolverContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/dnsresolver/dnsresolver.go:245:43: cannot use out (type *[32]byte) as type *[]interface {} in argument to _DNSResolverContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/dnsresolver/dnsresolver.go:271:43: cannot use out (type *[]byte) as type *[]interface {} in argument to _DNSResolverContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/dnsresolver/dnsresolver.go:297:43: cannot use out (type *bool) as type *[]interface {} in argument to _DNSResolverContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/dnsresolver/dnsresolver.go:323:43: cannot use out (type *string) as type *[]interface {} in argument to _DNSResolverContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/dnsresolver/dnsresolver.go:349:43: cannot use out (type *uint16) as type *[]interface {} in argument to _DNSResolverContract.contract.Call
../../go/pkg/mod/github.com/wealdtech/[email protected]/contracts/dnsresolver/dnsresolver.go:349:43: too many errors

Issue building app using go modules

When trying to build a newly started project using go modules, I get some issues coming out from go-ens.

To replicate, you can take the example from the README file and put it in a new file (e.g. main.go) sitting in an empty dir. Next you init the go modules.

$ go mod init
$ go mod tidy

Next, I try to run go build ./...:

$ go build ./...
# github.com/wealdtech/go-ens/contracts/dnsresolver
../../../../pkg/mod/github.com/wealdtech/[email protected]/contracts/dnsresolver/dnsresolver.go:23:6: undefined: abi.U256
# github.com/wealdtech/go-ens/contracts/deed
../../../../pkg/mod/github.com/wealdtech/[email protected]/contracts/deed/deed.go:23:6: undefined: abi.U256
# github.com/wealdtech/go-ens/contracts/auctionregistrar
../../../../pkg/mod/github.com/wealdtech/[email protected]/contracts/auctionregistrar/auctionregistrar.go:23:6: undefined: abi.U256
# github.com/wealdtech/go-ens/contracts/registry
../../../../pkg/mod/github.com/wealdtech/[email protected]/contracts/registry/registry.go:23:6: undefined: abi.U256
# github.com/wealdtech/go-ens/contracts/reverseresolver
../../../../pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseresolver/reverseresolver.go:23:6: undefined: abi.U256
# github.com/wealdtech/go-ens/contracts/reverseregistrar
../../../../pkg/mod/github.com/wealdtech/[email protected]/contracts/reverseregistrar/reverseregistrar.go:23:6: undefined: abi.U256
# github.com/wealdtech/go-ens/contracts/resolver
../../../../pkg/mod/github.com/wealdtech/[email protected]/contracts/resolver/resolver.go:23:6: undefined: abi.U256

Output of generated go.mod:

module github.com/deiu/test

go 1.14

require (
	github.com/ethereum/go-ethereum v1.9.18
	github.com/wealdtech/go-ens v1.0.0
)

Here is the output of go version:

$ go version
go version go1.14.6 linux/amd64

Sample code for reverse lookup not working

Hi, I'm trying to use the sample code results in the error caught panic: not a resolver:
I literally just use the sample code + my own Infura API key. It works for the normal non-reverse lookup:

	// 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 {
		panic(err)
	}

	// Resolve a name to an address.
	domain := "ethereum.eth"
	address, err := ens.Resolve(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)
	if err != nil {
		panic(err)
	}
	if reverse == "" {
		fmt.Printf("%s has no reverse lookup\n", address.Hex())
	} else {
		fmt.Printf("Name of %s is %s\n", address.Hex(), reverse)
	}

Can I use this library for the registration ENS?

I used https://app.ens.domains/ for registration ENS domain (rebsten network). Registration flow has two parts:

  1. Call commit function from smart contract 0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5
  2. Call registerWithConfig function from smart contract 0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5

Looks like this library doesn't have a wrapper for this smart contract and wrappers fol calls. Is there another way for creating an ENS domain via this library?

no contract code at given address

Hi
Thanks for the owesome module you created.
Recently i have an issue with the example you provide in the readme.
Here is the code snnipet i am using:

package main

import (
	"fmt"

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

func main() {
	// Replace SECRET with your own access token for this example to work.
	client, err := ethclient.Dial("https://cloudflare-eth.com")
	if err != nil {
		panic(err)
	}

	// Resolve a name to an address
	domain := "avsa.eth"
	address, err := ens.Resolve(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)
	if err != nil {
		panic(err)
	}
	if reverse == "" {
		fmt.Printf("%s has no reverse lookup\n", address.Hex())
	} else {
		fmt.Printf("Name of %s is %s\n", address.Hex(), reverse)
	}
}

However,the program raise the error:

panic: no contract code at given address

goroutine 1 [running]:
main.main()
        /root/go/src/ens/client/main2.go:21 +0x345
exit status 2

The above code worked well in the past several weeks, but failed today.Could you please give some suggestions to fix this problem?
Thank you!

ReverseResolver obfuscates transient rpc errors when resolved name is empty string

When calling the Name function on the reverse resolver contract, if an empty string is encountered, even if the error was a transient error, the original error is dropped in favor of errors.New("no resolution"). This makes it impossible to get access to the original rpc.HTTPError and decide whether there is really no reverse record for the given address or we simply encountered a transient error and should retry. For instance, It is common for providers like Alchemy to return a 429 status code indicating a rate-limit has been applied. In these scenarios we can check the rpc.HTTPError that is returned for a certain status code and decide for our selves whether we can retry.

Relevant code:

func ReverseResolve(backend bind.ContractBackend, address common.Address) (string, error) {
	resolver, err := NewReverseResolverFor(backend, address)
	if err != nil {
		return "", err
	}

	// Resolve the name
	name, err := resolver.Name(address)
	if name == "" {
		err = errors.New("no resolution")
	}

	return name, err
}

It would be more favorable to either keep the original error or wrap the original error so that consumers can unwrap if necessary, i.e:

err = fmt.Errorf("no resolution %w", err)

Can't decode Contenthash

Go version 1.16.5 linux/amd64
Version v3.4.6

I ran into an issue earlier where an ipns-ns encoded content hash isn't properly displayed:

package main

import (
	"fmt"

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

func main() {
	client, err := ethclient.Dial("http://127.0.0.1:8545")
	if err != nil {
		panic(err)
	}

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

	resolver, err := ens.NewResolver(client, domain)
	if err != nil {
		panic(err)
	}

	// Get content hash
	content, err := resolver.Contenthash()
	if err != nil {
		panic(err)
	}

	readable, err := ens.ContenthashToString(content)
	if err != nil {
		panic(err)
	}
	fmt.Printf(readable)
}

Which results in the following:

Address of esteroids.eth is 0x7448467f85FfA36Ca763C9E301e270F8ece0C2B8
/ipns �
       �b�%!�(MISSING)�G̍KC�T��R�M����}
ݸ

I've noticed similar behavior with the ENS plugin for coredns (possibly unrelated):

ipfs resolve -r /ipns/esteroids.eth/
Error: could not resolve name: "\\008\\001\\018 \\149\\011\\143b\\185%\\236\\197\\002G\\204\\141\\225\\008KC\\248T\\251\\196R\\137M\\154\\026\\151\\215\\242}\\010\\221\\184" is missing a DNSLink record (https://docs.ipfs.io/concepts/dnslink/)

Am I using this package incorrectly? Thanks for the great project, I've enjoyed working with your tools.

Examples not working with go 1.16

I think examples are not working anymore

this error happens when doing ens.Resolve(client, domain)

$:ens-updater dimiandre$ go run main.go 
# github.com/wealdtech/go-ens/v3/util
../../go/pkg/mod/github.com/wealdtech/go-ens/[email protected]/util/signer.go:31:11: cannot use func literal (type func(types.Signer, common.Address, *types.Transaction) (*types.Transaction, error)) as type bind.SignerFn in assignment
../../go/pkg/mod/github.com/wealdtech/go-ens/[email protected]/util/signer.go:44:11: cannot use func literal (type func(types.Signer, common.Address, *types.Transaction) (*types.Transaction, error)) as type bind.SignerFn in assignment

$:ens-updater dimiandre$ go version
go version go1.16 darwin/amd64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.