dart_ipfs library
Production-ready IPFS (InterPlanetary File System) implementation in Dart.
This library provides a complete IPFS implementation with support for:
- Full IPFS protocol compliance (CID, UnixFS, DAG-PB, Bitswap, DHT)
- P2P networking with production-grade cryptography
- Multiple deployment modes (offline, gateway, full P2P)
- HTTP Gateway and RPC API
- Mobile (Flutter) and web platform support
Quick Start
Offline Mode (Local Storage)
import 'package:dart_ipfs/dart_ipfs.dart';
void main() async {
final node = await IPFSNode.create(
IPFSConfig(offline: true),
);
await node.start();
// Add content
final cid = await node.addFile(data);
// print('Added: $cid');
// Retrieve content
final content = await node.get(cid);
await node.stop();
}
Gateway Mode (HTTP Server)
final node = await IPFSNode.create(
IPFSConfig(
offline: true,
gateway: GatewayConfig(
enabled: true,
port: 8080,
),
),
);
await node.start();
// Access at `http://localhost:8080/ipfs/<CID>`
Full P2P Mode
final node = await IPFSNode.create(
IPFSConfig(offline: false),
);
await node.start();
// print('Peer ID: ${node.peerID}');
Features
Core IPFS
- CID v0/v1: Content identifier support
- UnixFS: File system with chunking
- DAG-PB: MerkleDAG operations
- Pinning: Content persistence
- CAR Files: Import/export
Networking
- Bitswap 1.2.0: Block exchange protocol
- Kademlia DHT: Distributed routing
- PubSub: Real-time messaging
- MDNS: Local peer discovery
- Circuit Relay: NAT traversal
Services
- HTTP Gateway: Content serving
- RPC API: go-ipfs compatible
- IPNS: Mutable naming
- DNSLink: Domain resolution
- Metrics: Prometheus compatible
Architecture
The library is organized into layers:
- Core: CID, blocks, data structures
- Protocols: Bitswap, DHT, PubSub
- Services: Gateway, RPC, IPNS
- Transport: P2P networking
- Storage: Local datastore
Security
Production-grade cryptography:
- secp256k1: Elliptic curve (128-bit security)
- ChaCha20-Poly1305: AEAD encryption
- SHA-256: Content hashing
Platform Support
- ✅ Mobile (Flutter iOS/Android)
- ✅ Web (Dart Web)
- ✅ Desktop (Windows/macOS/Linux)
- ✅ Server (Dart VM)
Examples
See the example/ directory for:
- Offline content publishing
- P2P networking
- HTTP gateway
- Full node operation
Learn More
Classes
- BitswapConfig
- Configuration for the Bitswap protocol, including the optional HTTP gateway fallback used when P2P block exchange fails.
- Block
- Represents an IPFS block.
-
BlockStoreResult<
T> - A generic result returned by block store operations.
- CID
- A Content Identifier (CID) for content-addressed data in IPFS.
- CircuitRelayConfig
- Configuration for the circuit relay client.
- CryptoUtils
- Cryptographic utilities for secure key management.
- DagCborCodec
- Codec for DAG-CBOR.
- DagJsonCodec
- Codec for DAG-JSON.
- DHTConfig
- Configuration options for the DHT (Distributed Hash Table)
- Ed25519Signer
- Unified Ed25519 signing service.
- EncryptedData
- Result of AES-GCM encryption containing ciphertext and nonce.
- GatewayConfig
- Configuration for the IPFS HTTP Gateway.
- GraphsyncConfig
- Configuration for the Graphsync protocol handler.
- IBlock
- Interface for content-addressed data blocks.
- IBlockStore
- Interface for block storage operations.
- ImmutableBytes
- An immutable wrapper around a Uint8List with value-based equality.
- InMemoryBlockStore
- A simple in-memory block store implementation.
- IPFS
- Main entry point for the IPFS (InterPlanetary File System) implementation.
- IPFSConfig
- Configuration for an IPFS node.
- IPFSNode
- The main IPFS node implementation.
- IPFSWebNode
- A minimal IPFS node for web browsers.
- IPLDCodec
- Interface for all IPLD codecs in dart_ipfs_core.
- MetricsConfig
- Configuration options for telemetry and metrics collection.
- MultibaseUtils
- Helpers for multibase encoding/decoding used by CID and other multiformats.
- Multicodec
- Multicodec registry helpers for core IPLD and IPFS codecs.
- MultihashUtils
- Helpers for computing and decoding multihashes.
- NetworkConfig
- Network configuration for the IPFS node.
- ProtocolConfig
- Configuration for a specific protocol.
- PubSubMessage
- Represents a message published on a PubSub topic.
- QuicConnection
- Adapter implementing libp2p.TransportConn around a quic_lib Libp2pQuicConnection.
- QuicListener
- libp2p Listener implementation that wraps a quic_lib incoming connection stream.
- QuicTransport
- libp2p Transport implementation backed by the pure-Dart quic_lib package.
- RawCodec
- Codec for raw binary data.
- SecurityConfig
- Security-related configuration options for IPFS node
- StorageConfig
- Configuration options for IPFS storage.
- TurnServer
- Configuration for a TURN server used by WebRTC ICE.
- TypedMap
- An immutable, type-safe wrapper around a plain Map<String, dynamic>.
Enums
- GatewayMode
- Modes for retrieving content via the IPFSNode.
- NodeState
- Represents the possible states of an IPFSNode.
Extensions
- KeyPairExtensions on SimpleKeyPair
- Extension to help with key pair management and cleanup.
Typedefs
- MultihashInfo = MultihashInfo
-
Re-export of the underlying multihash info type from
dart_multihash.