Multiaddr class

A self-describing network address following the libp2p multiaddr format.

Multiaddr encodes a stack of network protocols and their values (e.g., /ip4/127.0.0.1/udp/1234/quic-v1) as an ordered list of MultiaddrComponents. It supports parsing from human-readable strings or compact binary bytes, and can serialize back to either form.

This type is used by the libp2p transport layer to identify peers and endpoints without ambiguity about which protocols are in use.

Example

final addr = Multiaddr.parse('/ip4/127.0.0.1/udp/1234/quic-v1');
final bytes = addr.toBytes();

See also:

Constructors

Multiaddr({required List<MultiaddrComponent> components})
Creates a Multiaddr from an explicit list of components.
Multiaddr.fromBytes(Uint8List bytes)
Parse from binary bytes.
factory
Multiaddr.parse(String address)
Parse from human-readable string (e.g., "/ip4/127.0.0.1/udp/1234/quic-v1").
factory

Properties

components List<MultiaddrComponent>
final
hashCode int
The hash code for this object.
no setteroverride
protocols List<String>
Get the protocol path (e.g., ["ip4", "udp", "quic-v1"]).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toBytes() Uint8List
Serialize to binary bytes.
toHumanReadable() String
Serialize to human-readable string.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override