{"id":28766956,"url":"https://github.com/base/go-ethereum-rpc","last_synced_at":"2026-02-27T13:38:19.391Z","repository":{"id":282950868,"uuid":"947331666","full_name":"base/go-ethereum-rpc","owner":"base","description":"A Golang JSON RPC server, forked from go-ethereum","archived":false,"fork":false,"pushed_at":"2025-03-17T19:52:52.000Z","size":89,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-06-17T12:46:42.463Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/base.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-12T14:19:04.000Z","updated_at":"2025-03-24T13:06:21.000Z","dependencies_parsed_at":"2025-03-17T20:50:49.006Z","dependency_job_id":null,"html_url":"https://github.com/base/go-ethereum-rpc","commit_stats":null,"previous_names":["base/go-ethereum-rpc"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/base/go-ethereum-rpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base%2Fgo-ethereum-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base%2Fgo-ethereum-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base%2Fgo-ethereum-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base%2Fgo-ethereum-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/base","download_url":"https://codeload.github.com/base/go-ethereum-rpc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base%2Fgo-ethereum-rpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29897846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T12:09:13.686Z","status":"ssl_error","status_checked_at":"2026-02-27T12:09:13.282Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-17T12:37:43.742Z","updated_at":"2026-02-27T13:38:19.383Z","avatar_url":"https://github.com/base.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-ethereum-rpc\n\nA fork of the `rpc` package in https://github.com/ethereum/go-ethereum with extensions.\n\nThe go-ethereum JSON RPC server is one of the most mature Golang RPC server implementations, but lacks some features that would make it a better general-purpose JSON RPC server. \nThis package is intended to be a minimal fork of ethereum/go-ethereum, such that it can easily be kept up to date with modifications to go-ethereum.\n\n## RPC Middleware\n\nThis package adds middleware support to the go-ethereum JSON RPC server. Middleware allows you to intercept and modify RPC method calls before and after they are executed. This provides a central hook to enable functionality such as:\n\n- Logging and metrics collection\n- Request validation\n- Authentication and authorization\n- Error handling and transformation\n- Caching\n- Rate limiting\n\n### Usage\n\n#### Setting Middlewares on a Server\n\n```go\n// Create a new RPC server\nserver := rpc.NewServer()\n\n// Set middlewares on the server\nserver.SetMiddlewares([]rpc.Middleware{\n    // Logging middleware\n    func(ctx context.Context, method string, args []reflect.Value, next func(ctx context.Context, method string, args []reflect.Value) rpc.MethodResult) rpc.MethodResult {\n        log.Printf(\"Calling method %s\", method)\n        \n        // Call the next middleware or the actual method\n        result := next(ctx, method, args)\n        \n        log.Printf(\"Method %s completed\", method)\n        if result.Error != nil {\n            log.Printf(\"Method %s failed with error: %v\", method, result.Error)\n        }\n        \n        return result\n    },\n    // Another middleware\n    func(ctx context.Context, method string, args []reflect.Value, next func(ctx context.Context, method string, args []reflect.Value) rpc.MethodResult) rpc.MethodResult {\n        // Do something before the method call\n        \n        result := next(ctx, method, args)\n        \n        // Do something after the method call\n        \n        return result\n    },\n})\n```\n\n#### Middleware Execution Order\n\nMiddlewares are executed in the order they are provided to `SetMiddlewares`. The \"before\" parts are executed in the order they were added, and the \"after\" parts are executed in reverse order.\n\nFor example, if you add middlewares A, B, and C in that order, the execution flow will be:\n\n```\nA (before) -\u003e B (before) -\u003e C (before) -\u003e Method -\u003e C (after) -\u003e B (after) -\u003e A (after)\n```\n\n#### Middleware Function Signature\n\n```go\ntype Middleware func(ctx context.Context, method string, args []reflect.Value, next func(ctx context.Context, method string, args []reflect.Value) MethodResult) MethodResult\n```\n\nWhere:\n- `ctx` is the context for the method call\n- `method` is the name of the method being called\n- `args` are the arguments to the method\n- `next` is the next middleware in the chain, or the actual method if this is the last middleware\n- `MethodResult` is a struct containing the result and error from the method call\n\n### Examples\n\n#### Logging Middleware\n\n```go\nfunc LoggingMiddleware(ctx context.Context, method string, args []reflect.Value, next func(ctx context.Context, method string, args []reflect.Value) rpc.MethodResult) rpc.MethodResult {\n    start := time.Now()\n    log.Printf(\"Calling method %s\", method)\n    \n    result := next(ctx, method, args)\n    \n    log.Printf(\"Method %s completed in %v\", method, time.Since(start))\n    if result.Error != nil {\n        log.Printf(\"Method %s failed with error: %v\", method, result.Error)\n    }\n    \n    return result\n}\n```\n\n### Best Practices\n\n1. **Keep middlewares focused**: Each middleware should have a single responsibility.\n2. **Consider performance**: Be mindful of performance implications, especially for high-traffic RPC servers.\n3. **Use context for data sharing**: Use context values to pass data between middlewares.\n4. **Handle errors appropriately**: Decide whether to pass errors through or transform them.\n5. **Order matters**: Consider the order of middleware execution carefully.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbase%2Fgo-ethereum-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbase%2Fgo-ethereum-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbase%2Fgo-ethereum-rpc/lists"}