IPFS data sharing costs and limits

I’m very new in IPFS and wrote a simple code to store and retrieve a JSON in IPFS as follow:

const IPFS = require('ipfs-mini');
const ipfs = new IPFS({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });
ipfs.addJSON({ somevalue: 2, name: 'Nick' }, (err, result) => {
  if (err){
    console.log(err);
  }
  console.log(result);
});

// result 'QmYzWWCvYhqU6d5VvRvVwgbpqM9J3HH8TMbns9UvFSSvBf'

ipfs.catJSON("QmYzWWCvYhqU6d5VvRvVwgbpqM9J3HH8TMbns9UvFSSvBf", (err, result) => {
if (err){
	console.log(err);
}
    console.log(result);
});

Now, I have some questions. First: Is this code right and really store and retrieve JSON?
Is there a cost to storing data?
Is there a limit (in size or number of files)?
Also, do you know how many computers the data is stored in?

Thanks in advance

IPFS will not automatically distribute your data on other nodes. It’s more like bittorrent, it’ll creates a global filesystem namespace where you can add files on your machine, tell others about them (e.g., /ipfs/Qm…) and they can then use the IPFS network to (a) find where the files are stored (your machine) and (b) fetch them.

If you want to actually get others to store your files, you’ll have to pay them out of band. If you google “IPFS pinning service”, you’ll find some existing services willing to do this.

There’s a couple of ways to distribute content throughout the IPFS network.

  1. You can announce to the DHT that you are a provider of a particular content hash using ipfs dht provide .....
  2. Request your content via all known public gateways, this will help to cache the content at least temporarily across the various gateway nodes
  3. Pay a service to pin your content

As for storage limits, realistically speaking there is no upper limit on the amount of data that can be put on the network. There’s a couple things to be aware of that will influence how much content your node can host in a reliable, and efficient manner, couple of things to research:

  • Datastore Type (BadgerDS, LevelDB, etc…)
  • number of pins on your node this is very important, as pinning a large number of files can cause degraded performance
  • OS level file descriptor limit
  • Underlying filesystem of your datastore (ext4, ntfs, etc…)
1 Like