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.
pip install multiaddrVerified import paths — ran on the pinned version, not inferred.
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.
Upgrade your Python environment to version 3.10 or newer. The current PyPI release explicitly requires Python >=3.10 and <4.0.
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)`.
Install `trio` explicitly if you need async DNS resolution: `pip install multiaddr[full]` or `pip install trio`.
Install the package using pip: `pip install multiaddr`
Provide exactly one of `string_addr` (a string) or `bytes_addr` (bytes) to the `Multiaddr` constructor. Example: `m = Multiaddr('/ip4/127.0.0.1/tcp/8080')` or `m = Multiaddr(bytes_addr=b'\x04\x7f\x00\x00\x01\x06\x1f\x90')`Ensure the multiaddr string uses standard and supported protocols. If using a custom or newer protocol, check for library updates or verify the protocol's definition.
Review the multiaddr string for correct syntax and valid protocol values. Refer to the multiaddr specification for proper formatting, e.g., `/ip4/127.0.0.1/tcp/8080`.