Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no contract code at given address #19

Closed
lurenxiao1998 opened this issue Apr 19, 2022 · 2 comments
Closed

no contract code at given address #19

lurenxiao1998 opened this issue Apr 19, 2022 · 2 comments

Comments

@lurenxiao1998
Copy link

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!

@mcdee
Copy link
Collaborator

mcdee commented Apr 19, 2022

As far as I am aware https://cloudflare-eth.com is not a valid Ethereum JSON-RPC endpoint, which is why this is failing. Please could you try this with a valid Ethereum JSON-RPC endpoint as per the example?

@lurenxiao1998
Copy link
Author

Oh.It works for me when i change https://cloudflare-eth.com to https://mainnet.infura.io/v3.
Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants