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
bandwidthMetrics Stream<Map<String, dynamic>>
Returns a Stream of bandwidth metrics as a Map.
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
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
hashCode int
The hash code for this object.
no setterinherited
isRunning bool
Whether the node is currently running.
no setter
mfs → MFSManager
Returns the Mutable File System (MFS) manager.
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
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
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) 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.
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.
publishIPNS(String cid, {required String keyName}) Future<void>
Returns a Future that completes when an IPNS record is published for the given cid.
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.