firebasegoogle-cloud-platformgoogle-cloud-functionsipfs

Ipfs module not working with firebase functions


I am trying to use firebase cloud functions to store data on IPFS. I was able to install ipfs-mini package.

const IPFS = require('ipfs-mini');
const ipfs = new IPFS({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });

ipfs.add("testdata")
    .then(function(result){               
      response.send(result);
    })  
    .catch(function (err) {            
      response.send(err)
    })

However I get error as in screenshot


Solution

  • Based on your error getaddrinfo ENOTFOUND ..., it is probably because you are on the free "Spark" plan. You need to be on the "Flame" or "Blaze" pricing plan.

    As a matter of fact, the free "Spark" plan "allows outbound network requests only to Google-owned services". See https://firebase.google.com/pricing/ (hover your mouse on the question mark located after the "Cloud Functions" title)

    Since IPFS is not a Google-owned service, you need to switch to the "Flame" or "Blaze" plan.

    Note that if you take the "Blaze" plan, you will still be able to take advantage of the free tier offered by the free "Spark" plan (See the "Free usage from Spark plan included" remark in the top-right cell of the pricing table)