dart_libp2p
4.12.2, released 9 days ago by werkswinkel.com
A Dart implementation of the libp2p networking stack for peer-to-peer applications.
What it does
Provides a modular networking stack supporting multiple transports like TCP and UDX, Noise security protocol, stream multiplexing via Yamux, and peer discovery. It enables building decentralized peer-to-peer applications and protocols in Dart.
AI-written summary of version 4.12.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are building a peer-to-peer application in Dart or Flutter.
- You need encrypted and authenticated connections using the Noise protocol.
- You require customizable transport layers like TCP or UDX.
Skip it when
- You only need a simple client to talk to a traditional REST, GraphQL, or WebSocket backend.
- You require built-in QUIC transport support.
Strengths
- Modular architecture with pluggable transports, security, and multiplexers.
- Built-in NAT traversal tools including hole punching and relay support.
- Comprehensive suite of core libp2p protocols and event systems.
Weaknesses
- Does not support the QUIC transport protocol.
- Some advanced integration tests and features require external tools or separate packages.
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 23
Add the dependency to pubspec.yaml and configure transports, security, and options in code when initializing the Libp2p host.
import 'package:dart_libp2p/dart_libp2p.dart';
import 'package:dart_libp2p/config/config.dart' as p2p_config;
import 'package:dart_libp2p/core/crypto/ed25519.dart' as crypto_ed25519;
import 'package:dart_libp2p/p2p/security/noise/noise_protocol.dart';
import 'package:dart_libp2p/p2p/transport/udx_transport.dart';
import 'package:dart_libp2p/p2p/transport/connection_manager.dart' as p2p_conn_manager;
void main() async {
final keyPair = await crypto_ed25519.generateEd25519KeyPair();
final connMgr = p2p_conn_manager.ConnectionManager();
final options = [
p2p_config.Libp2p.identity(keyPair),
p2p_config.Libp2p.connManager(connMgr),
p2p_config.Libp2p.transport(UDXTransport(connManager: connMgr)),
p2p_config.Libp2p.security(await NoiseSecurity.create(keyPair)),
];
final host = await p2p_config.Libp2p.new_(options);
await host.start();
print('Host ID: \${host.id}');
await host.close();
}Works with
Packages commonly used together with dart_libp2p: ones it builds on, ones built on it, and its own family.
- cryptodart_libp2p depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- uuiddart_libp2p depends on itGenerates and parses RFC‑4122/9562 UUIDs (v1‑v8) for Dart.
- stack_tracedart_libp2p depends on itProvides parsing, inspection, and readable formatting of Dart stack traces.
- asyncdart_libp2p depends on itUtility classes and helpers that extend Dart's async library.
- argsdart_libp2p depends on itLibrary for parsing raw command-line arguments into options and values using GNU and POSIX styles.
- loggingdart_libp2p depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- convertdart_libp2p depends on itEncoders and decoders for converting between different data representations.
- fixnumdart_libp2p depends on itProvides 32‑ and 64‑bit signed fixed‑width integer types for Dart.