diff --git a/jsonrpc/transport/http.go b/jsonrpc/transport/http.go index 4b4627e2..01c72a66 100644 --- a/jsonrpc/transport/http.go +++ b/jsonrpc/transport/http.go @@ -2,6 +2,7 @@ package transport import ( "encoding/json" + "fmt" "github.com/umbracle/ethgo/jsonrpc/codec" "github.com/valyala/fasthttp" @@ -66,6 +67,10 @@ func (h *HTTP) Call(method string, out interface{}, params ...interface{}) error return err } + if sc := res.StatusCode(); sc != fasthttp.StatusOK { + return fmt.Errorf("status code is %d. response = %s", sc, string(res.Body())) + } + // Decode json-rpc response var response codec.Response if err := json.Unmarshal(res.Body(), &response); err != nil {