wealdtech / go-ens

Apache License 2.0
90 stars 33 forks source link

no contract code at given address #19

Closed lurenxiao1998 closed 2 years ago

lurenxiao1998 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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