IPFS class

Main entry point for the IPFS (InterPlanetary File System) implementation.

This class provides a high-level interface for interacting with IPFS, including content storage, retrieval, pinning, and networking operations.

Example Usage:

final ipfs = IPFS();

// Add content
final block = await Block.fromData(utf8.encode('Hello IPFS'));
await ipfs.store(block);

// Retrieve content
final retrieved = await ipfs.retrieve(block.cid.toString());

For more advanced usage, consider using IPFSNode directly which provides full control over configuration, networking, and services.

See also:

  • IPFSNode for full-featured node operations
  • Block for content-addressed data storage
  • CID for content identifier operations

Constructors

IPFS.fromNode(IPFSNode node)
Wraps an existing IPFSNode in the high-level IPFS facade.
factory

Properties

addresses → List<String>
Multiaddresses this node is listening on.
no setter
bandwidthIn → int
Total bytes received by the node since it started.
no setter
bandwidthMetrics → Stream<Map<String, dynamic>>
Stream of bandwidth metrics for this node.
no setter
bandwidthOut → int
Total bytes sent by the node since it started.
no setter
connectedPeers → Future<List<String>>
Currently connected swarm peer IDs.
no setter
dhtPeerCount → int
Number of peers currently in the DHT routing table.
no setter
discoveredPeers → Stream<Peer>
Broadcast stream of peers discovered via mDNS on the local network.
no setter
hashCode → int
The hash code for this object.
no setterinherited
onNewContent → Stream<String>
Stream of new content CIDs added to the node.
no setter
peerID → String
Gets the peer ID of the IPFS node.
no setter
peerId → String
Gets the peer ID of the IPFS node.
no setter
pinnedCids → Future<List<String>>
CIDs currently pinned by this node.
no setter
publicKey → Future<String>
The public key of this node as a base64-encoded protobuf.
no setter
pubsubMessages → Stream<PubSubMessage>
Stream of incoming PubSubMessages for all subscribed topics.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addDirectory(Map<String, dynamic> directoryContent, {int shardThreshold = 0}) → Future<String>
Adds a directory to IPFS.
addFile(Uint8List data) → Future<String>
Adds a file to the IPFS network from its raw data.
addFileStream(Stream<List<int>> dataStream) → Future<String>
Adds a file to the IPFS network from a stream of bytes.
cat(String cid) → Future<Uint8List?>
Gets the raw content associated with the given cid.
connectToPeer(String multiaddr) → Future<void>
Connects to a peer using its multiaddr.
disconnectFromPeer(String peerIdOrAddr) → Future<void>
Gracefully disconnects from the peer identified by peerIdOrAddr.
exportCAR(String cid) → Future<Uint8List>
Exports a CAR file for the given CID.
findProviders(String cid) → Future<List<String>>
Finds providers for a CID.
get(String cid, {String path = ''}) → Future<Uint8List?>
Gets the content of a file or directory from IPFS.
getHealthStatus() → Future<Map<String, dynamic>>
Gets the health status of all node subsystems.
importCAR(Uint8List carFile) → Future<void>
Imports a CAR file.
keyExport(String name) → Future<Uint8List>
Returns the raw 32-byte Ed25519 private key seed stored under name.
keyGen(String name, {String type = 'ed25519', int? size}) → Future<String>
Generates a new Ed25519 key pair stored under name and returns its IPNS name (base36-encoded libp2p-key CID).
keyImport(String name, Uint8List privateKey) → Future<String>
Imports a raw 32-byte Ed25519 private key seed under name and returns its IPNS name.
keyList() → Future<List<String>>
Lists the key names stored in the node's keystore.
keyRm(String name) → Future<void>
Removes the key stored under name. The default 'self' key cannot be removed.
ls(String cid) → Future<List<Link>>
Lists the contents of a directory in IPFS.
messagesFor(String topic) → Stream<PubSubMessage>
Stream of incoming PubSubMessages filtered to a single topic.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pin(String cid) → Future<void>
Pins a CID to prevent it from being garbage collected.
provide(String cid) → Future<void>
Announces to the network that this node provides the given cid.
publish(String topic, String message) → Future<void>
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>
Publishes an IPNS record.
pubsubLs() → List<String>
Topics this node is currently subscribed to.
pubsubPeers(String topic) → Future<List<String>>
Peers known to be subscribed to topic.
requestBlock(String cid, String peerID) → Future<void>
Requests a block from the network using Bitswap.
Resolves a DNSLink to its corresponding CID.
resolveIPNS(String ipnsName) → Future<String>
Resolves an IPNS name to its corresponding CID.
resolvePeerId(String peerId) → List<String>
Resolves a peerId to its known multiaddresses.
restart() → Future<void>
Restarts the IPFS node.
setGatewayMode(GatewayMode mode, {String? customUrl}) → void
Sets the mode used for retrieving content.
start() → Future<void>
Starts the IPFS node.
stats() → Future<NodeStats>
Gets the node's statistics.
stop() → Future<void>
Stops the IPFS node.
subscribe(String topic) → Future<void>
Subscribes to a PubSub topic.
toString() → String
A string representation of this object.
inherited
unpin(String cid) → Future<void>
Unpins a CID.
unsubscribe(String topic) → Future<void>
Unsubscribes from a PubSub topic.

Operators

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

Static Methods

create({IPFSConfig? config}) → Future<IPFS>
Creates a new IPFS node.