{"id":6727,"library":"multiaddr","title":"Multiaddr Python Implementation","description":"Multiaddr is a Python library that provides an implementation of jbenet's multiaddr specification, designed for future-proof, composable, and efficient network addresses. It aims to solve ambiguities in traditional network addressing by making addresses self-describing, specifying both protocol and network address. The library supports various protocols like IPv4, IPv6, TCP, UDP, DNS, and more, offering both human-readable and machine-readable representations. It is currently at version 0.2.0 and receives active development and releases.","status":"active","version":"0.2.0","language":"en","source_language":"en","source_url":"https://github.com/multiformats/py-multiaddr","tags":["networking","p2p","multiformats","addressing","libp2p"],"install":[{"cmd":"pip install multiaddr","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required Python runtime version.","package":"python","optional":false},{"reason":"Required for asynchronous DNS resolution via the DNSADDR protocol.","package":"trio","optional":true}],"imports":[{"symbol":"Multiaddr","correct":"from multiaddr import Multiaddr"}],"quickstart":{"code":"from multiaddr import Multiaddr\n\n# Construct a Multiaddr from a string\naddr_str = \"/ip4/127.0.0.1/tcp/8080\"\nm1 = Multiaddr(addr_str)\nprint(f\"Multiaddr from string: {m1}\")\nprint(f\"Protocols: {[p.name for p in m1.protocols()]}\")\n\n# Construct from bytes\nm2 = Multiaddr(m1.to_bytes())\nprint(f\"Multiaddr from bytes: {m2}\")\n\n# Encapsulate another Multiaddr\nwebsocket_addr = Multiaddr(\"/ws\")\nencapsulated_addr = m1.encapsulate(websocket_addr)\nprint(f\"Encapsulated Multiaddr: {encapsulated_addr}\")\n\n# Decapsulate a protocol\ndecapsulated_addr = encapsulated_addr.decapsulate(websocket_addr)\nprint(f\"Decapsulated Multiaddr: {decapsulated_addr}\")\n\nassert str(m1) == str(decapsulated_addr)","lang":"python","description":"This quickstart demonstrates how to create Multiaddr instances from strings and bytes, retrieve the list of protocols, and perform encapsulation and decapsulation operations, which are core functionalities of the library."},"warnings":[{"fix":"Upgrade your Python environment to version 3.10 or newer. The current PyPI release explicitly requires Python >=3.10 and <4.0.","message":"Support for Python versions prior to 3.10 was dropped starting from version 0.0.10. Attempting to use `multiaddr` on older Python environments (e.g., Python 3.4-3.9) will result in incompatibility errors.","severity":"breaking","affected_versions":">=0.0.10"},{"fix":"Remove the `bytes_addr=` keyword when initializing `Multiaddr` from a byte string, i.e., use `Multiaddr(my_bytes)` instead of `Multiaddr(bytes_addr=my_bytes)`.","message":"The `bytes_addr` keyword argument for `Multiaddr` constructor when creating an instance from bytes is deprecated. Instead of `Multiaddr(bytes_addr=some_bytes)`, pass the bytes directly: `Multiaddr(some_bytes)`.","severity":"deprecated","affected_versions":"All versions up to 0.2.0"},{"fix":"Install `trio` explicitly if you need async DNS resolution: `pip install multiaddr[full]` or `pip install trio`.","message":"Asynchronous DNS resolution (via the DNSADDR protocol) requires the optional `trio` library. If you intend to use this feature, ensure `trio` is installed alongside `multiaddr`. Without it, attempts to resolve DNS-based multiaddrs might fail or lack async capabilities.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}