MESC (Multi-Endpoint RPC Service Configuration)

repository·main·Indexed 41 days ago

https://github.com/paradigmxyz/mesc

A utility and standard for creating and managing RPC configurations. It provides a CLI for managing and pinging blockchain network endpoints, as well as client libraries for Rust (v0.2.1), Python, and Go to enable endpoint discovery and metadata retrieval across different tools and profiles.

Tokens
44.8K
Snippets
141
Records
203
Agent score
50%

What's inside MESC

  1. Available MESC language implementations

    main

    MESC provides implementations for several common languages in the cryptocurrency ecosystem. You can use the following libraries depending on your development environment:

    • CLI: Command Line Interface
    • Go: Go implementation
    • Python: Python implementation
    • Rust: Rust implementation
    • TypeScript: TypeScript implementation
  2. What is Multiple Endpoint Single Config (MESC)?

    main

    MESC is a standard for configuring RPC endpoints in crypto tools. It aims to solve the problem of fragmented RPC configuration by providing a single source of truth that can be shared across different tools, programming languages, and environments.

    Core Design Goals:

    • Interoperability: Make it easy to share RPC configuration data across tools, languages, and environments.
    • Scalability: Make it easy to manage the configuration of a large number of RPC endpoints (e.g., across mainnets, testnets, chainforks, and rollups).

    Key Features of the Standard:

    • Supports multiple providers for multiple chains.
    • Allows selecting a default endpoint for each chain.
    • Supports both environment variables and configuration files.
    • OS-agnostic and language-agnostic.
    • Backwards compatible with existing solutions like ETH_RPC_URL.
  3. What is MESC and why use it?

    main

    MESC is a standardized configuration solution for managing multiple RPC endpoints across various chains (mainnet, testnets, rollups, etc.). It addresses the limitations of single-variable approaches like ETH_RPC_URL by providing a single, language-agnostic, and OS-agnostic source of truth.

    Key capabilities:

    • Multi-chain/Multi-provider support: Specify multiple providers for multiple different chains.
    • Default selection: Define a default endpoint for each specific chain.
    • Flexible configuration: Supports both environment variables and configuration files.
    • Interoperability: Acts as a shared configuration layer across different tools and programming languages.
    • Metadata storage: Allows developers to store tool-specific configuration data within MESC's metadata, potentially eliminating the need for custom config files (e.g., in Go implementations).
  4. What is MESC (Multiple Endpoint Shared Configuration)?

    main

    MESC (Multiple Endpoint Shared Configuration) is a standardized approach for configuring RPC endpoints. It allows a user to create a single RPC configuration that is shared across all RPC tools on their system, serving as a single source of truth.

    Key capabilities include:

    • Specifying multiple providers for multiple chains.
    • Selecting a default endpoint for each chain.
    • Using either environment variables or configuration files.
    • Maintaining OS-agnostic and language-agnostic compatibility.
  5. Understand MESC metadata scopes

    main

    MESC configurations support three distinct scopes for storing optional or idiosyncratic metadata alongside core RPC data. This allows tools to attach context-specific information that can be used for filtering, rate limiting, or identification.

    Note that the contents of these metadata fields are loosely specified to allow for future-proofing and tool-specific use cases. Tools consuming MESC data may choose to ignore these fields if they do not recognize the keys.

  6. How MESC is activated and its compatibility

    main

    MESC is an opt-in specification. It does not interfere with existing tools that use standard configuration methods like ETH_RPC_URL. MESC only becomes active when a user explicitly sets one or more of the following environment variables:

    • MESC_MODE
    • MESC_PATH
    • MESC_ENV

    If these variables are not set, tools will continue to function using their original configuration logic.

  7. Understand MESC configuration abstractions

    main

    MESC uses several layers of metadata and profiles to manage complex endpoint configurations:

    • Metadata Layers:
      • global_metadata: Information applicable across the entire configuration.
      • profile_metadata: Information specific to a particular tool or mode of operation.
      • endpoint_metadata: Information specific to an individual endpoint (e.g., API keys, rate limits, or organizational labels).
    • Profiles: Allow different default endpoints and settings to be assigned to specific tools or modes of operation.
    • Storage: Configuration can be stored in a JSON file or via environment variables, allowing for flexible deployment (e.g., version-controlled files vs. dynamic environment variables).
  8. How to opt-in to the MESC standard

    main
    MESC is an opt-in standard to ensure backward compatibility. Tools that support MESC will only attempt to use the MESC configuration if a user has explicitly enabled it by setting a MESC-specific environment variable in their environment. If the environment variable is not present, tools should fall back to their existing configuration methods.
  9. What are MESC Profiles and how do they work?

    main

    Profiles are an optional feature that allow individual tools to customize their own MESC settings independently of the global configuration.

    Profiles enable a tool to:

    • Set its own default_endpoint.
    • Set specific default endpoints for each network via network_defaults.
    • Override global metadata with tool-specific profile_metadata.
    • Disable MESC for that specific tool using the use_mesc flag without affecting the global MESC configuration.

    Fallback Behavior:

    • If a MESC query does not specify a profile, the global configuration values are used.
    • If a query specifies a profile that does not exist, or if the profile is missing specific configuration keys, MESC falls back to the global configuration values.
  10. How MESC resolves endpoint queries

    main

    When a user provides an endpoint identifier (e.g., via a CLI flag like -r <ENDPOINT>), a MESC-compliant library must resolve that input into a URL by searching in this specific order:

    1. Endpoint names
    2. Chain ID
    3. Network name

    Supported query types include URLs, endpoint names, network names, or chain IDs.

  11. Set up a MESC profile

    main

    You can set up a profile using one of two methods:

    Use the mesc CLI tool with the setup subcommand to interactively configure a new profile.

    mesc setup

    Method 2: Manual Configuration

    Manually add a new entry to the profiles key within your mesc.json file. Use the following JSON structure as a template:

    {
        "name": "PROFILE_NAME",
        "default_endpoint": null,
        "network_defaults": {},
        "profile_metadata": {},
        "use_mesc": true
    }