mesc/python
History 2023-12-03 00:53:50 -08:00
..
mesc unify python and rust behaviors 2023-12-03 00:53:50 -08:00
pyproject.toml initial commit 2023-11-11 14:41:13 -08:00
README.md revise python implementation for language agnosticism 2023-11-11 21:56:04 -08:00

Python MESC Implementation

This is a reference implementation of the Python MESC Standard

Installation

From PyPI

pip install mesc

From Source

git clone https://github/paradigmxyz/mesc
cd mesc
pip install ./

Example Usage

import mesc

default_network = mesc.get_default_network()
default_goerli_endpoint = mesc.get_default_endpoint(chain_id=5)
local_goerli_endpoint = mesc.get_endpoint('local_goerli')

Reference

Basic data structures

class Endpoint(TypedDict):
    url: str
    chain_id: int
    endpoint_extras: Mapping[str, Any]

Basic read functions

import mesc

# get the default network
chain_id = mesc.get_default_network()

# get the default endpoint of a network
endpoint = mesc.get_default_endpoint(5)

# get the default network for a particular tool
chain_id = mesc.get_default_network(profile='xyz_tool')

# get the default endpoint of a network for a particular tool
endpoint = mesc.get_default_endpoint(5, profile='xyz_tool')

# get an endpoint by name
endpoint = mesc.get_endpoint_by_name(name)

# parse a user-provided string into a matching endpoint
# (first try 1. endpoint name, then 2. chain id, and then 3. network name)
endpoint = mesc.parse_endpoint(user_str, profile='xyz_tool')

# find all endpoints matching given criteria
endpoints = mesc.find_endpoints(chain_id=5)