IPFSNode class

The main IPFS node implementation.

Provides high-level APIs for content addressing, publishing, DHT operations, and peer-to-peer networking.

Platform Note: Storage behavior is platform-dependent. On VM platforms, it uses the local file system. On Web platforms, it uses IndexedDB via the IpfsPlatform abstraction.

IPFSNode acts as a facade, orchestrating specialized managers:

  • ContentManager: Handles files, directories, pinning, and CAR files.
  • NetworkManager: Handles peer connectivity and provider discovery.
  • ProtocolManager: Handles PubSub, IPNS, and DNSLink.

Constructors

IPFSNode.fromContainer(ServiceContainer _container)
Creates an IPFSNode from a pre-configured service container.

Properties

addresses → List<String>
Returns a List of multiaddresses this node is listening on.
no setter
bandwidthIn → int
Returns total bytes received by the P2P node since it started.
no setter
bandwidthMetrics → Stream<Map<String, dynamic>>
Returns a Stream of bandwidth metrics as a Map.
no setter
bandwidthOut → int
Returns total bytes sent by the P2P node since it started.
no setter
bitswap → BitswapHandler?
Returns the BitswapHandler instance, or null if not registered.
no setter
blockStore → BlockStore
Returns the underlying BlockStore.
no setter
connectedPeers → Future<List<String>>
Returns a Future that resolves to a List of currently connected peer IDs.
no setter
datastore → Datastore
Returns the underlying Datastore.
no setter
denylistService → DenylistService?
Returns the DenylistService instance, or null if not registered.
no setter
dhtClient → DHTClient
Returns the DHTClient for peer and content discovery.
no setter
dhtHandler → DHTHandler?
Returns the DHTHandler instance, or null if not registered.
no setter
dhtPeerCount → int
Returns the number of peers currently in the Kademlia DHT routing table.
no setter
discoveredPeers → Stream<Peer>
Returns a broadcast Stream of peers discovered via mDNS on the local network.
no setter
hashCode → int
The hash code for this object.
no setterinherited
ipns → IPNSHandler?
Returns the IPNSHandler instance, or null if not registered.
no setter
isRunning → bool
Whether the node is currently running.
no setter
metricsCollector → MetricsCollector?
Returns the MetricsCollector instance, or null if not registered.
no setter
mfs → MFSManager
Returns the Mutable File System (MFS) manager.
no setter
mobileCoordinator → MobileLifecycleCoordinator?
Returns the MobileLifecycleCoordinator, or null if not registered.
no setter
networkManager → NetworkManager
Returns the underlying NetworkManager.
no setter
onNewContent → Stream<String>
Returns a Stream of new content CIDs added to this node.
no setter
peerID → String
Returns the peer ID of this node.
no setter
peerId → String
Returns the peer ID of this node.
no setter
peerIdOrNull → String?
Returns the peer ID, or null when the node has no network identity (offline mode). Callers that need the repo-persisted identity regardless of network state should derive it from the identity seed (see Libp2pRouter.persistedPeerId).
no setter
pinnedCids → Future<List<String>>
Returns a Future that resolves to a List of CIDs currently pinned by this node.
no setter
plugins → PluginManager
Returns the Plugin manager.
no setter
publicKey → Future<String>
Returns a Future that resolves to the public key of this node as a base64 encoded protobuf.
no setter
pubsubMessages → Stream<PubSubMessage>
Returns a Stream of incoming PubSubMessages for all subscribed topics.
no setter
reprovider → Reprovider?
Returns the periodic Reprovider service, if DHT is enabled.
no setter
router → RouterInterface?
Returns the RouterInterface used for networking, or null if not available.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
securityManager → SecurityManager
Returns the SecurityManager.
no setter
state → NodeState
Returns the current state of the node.
no setter

Methods

addDirectory(Map<String, dynamic> directoryContent, {int shardThreshold = 0}) → Future<String>
Returns a Future that resolves to the CID of the added directoryContent.
addFile(Uint8List data) → Future<String>
Returns a Future that resolves to the CID of the added file data.
addFileStream(Stream<List<int>> dataStream) → Future<String>
Returns a Future that resolves to the CID of the added file from dataStream.
cat(String cid) → Future<Uint8List?>
Returns a Future that resolves to the raw content associated with the given cid.
connectToPeer(String multiaddr) → Future<void>
Returns a Future that completes when the node manually connects to a peer using its multiaddr.
disconnectFromPeer(String peerIdOrAddr) → Future<void>
Returns a Future that completes when the node gracefully disconnects from a peer identified by peerIdOrAddr.
exportCAR(String cid) → Future<Uint8List>
Returns a Future that resolves to the CAR file bytes for the given cid.
findProviders(String cid) → Future<List<String>>
Returns a Future that resolves to a List of multiaddresses for providers of the given cid.
get(String cid, {String path = ''}) → Future<Uint8List?>
Returns a Future that resolves to the content of a file or directory associated with the given cid.
getHealthStatus() → Future<Map<String, dynamic>>
Returns a Future that resolves to a health status map for all subsystems.
importCAR(Uint8List carFile) → Future<void>
Returns a Future that completes when the given CAR (Content Addressable Archive) file carFile is imported.
keyExport(String name) → Future<Uint8List>
Returns a Future that resolves to the raw 32-byte Ed25519 private key seed stored under name.
keyGen(String name, {String type = 'ed25519', int? size}) → Future<String>
Returns a Future that resolves to the IPNS name (base36-encoded libp2p-key CID) of a newly generated Ed25519 key stored under name.
keyImport(String name, Uint8List privateKey) → Future<String>
Returns a Future that resolves to the IPNS name of the key imported under name.
keyList() → Future<List<String>>
Returns a Future that resolves to a List of key names stored in the node's encrypted keystore.
keyRm(String name) → Future<void>
Returns a Future that completes when the key stored under name is removed from the keystore.
ls(String cid) → Future<List<Link>>
Returns a Future that resolves to a List of Links representing the contents of an IPFS directory.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pin(String cid) → Future<void>
Returns a Future that completes when the given cid is pinned to prevent it from being garbage collected.
publish(String topic, String message) → Future<void>
Returns a Future that completes when the node publishes a message to a PubSub topic.
publishData(String topic, Uint8List data) → Future<void>
Publishes a binary payload to a PubSub topic.
publishIPNS(String cid, {required String keyName}) → Future<String>
Returns a Future that resolves to the IPNS name (base36-encoded peer ID) published for the given cid.
pubsubLs() → List<String>
Returns a List of topics this node is currently subscribed to.
pubsubPeers(String topic) → Future<List<String>>
Returns a Future that resolves to the peers known to be subscribed to topic.
requestBlock(String cid, Peer peer) → Future<void>
Returns a Future that completes when a specific block associated with cid is requested from a peer via Bitswap.
Returns a Future that resolves to the CID corresponding to the given domainName via DNSLink.
resolveIPNS(String name) → Future<String>
Returns a Future that resolves to the CID corresponding to the IPNS name.
resolvePeerId(String peerIdStr) → List<String>
Resolves a peerIdStr to its known multiaddresses.
restart() → Future<void>
Returns a Future that completes when the IPFS node has restarted by performing a stop and then a start.
setGatewayMode(GatewayMode mode, {String? customUrl}) → void
Sets the mode for retrieving content.
start() → Future<void>
Returns a Future that completes when the IPFS node and all its subsystems have started.
stop() → Future<void>
Returns a Future that completes when the IPFS node has stopped gracefully, releasing all resources.
subscribe(String topic) → Future<void>
Returns a Future that completes when the node subscribes to a PubSub topic.
toString() → String
A string representation of this object.
inherited
unpin(String cid) → Future<bool>
Returns a Future that resolves to true if the given cid was successfully unpinned from IPFS.
unsubscribe(String topic) → Future<void>
Returns a Future that completes when the node unsubscribes from a PubSub topic.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

create(IPFSConfig config) → Future<IPFSNode>
Returns a Future that resolves to an IPFSNode built from the config.