Integrating web3 in cloud functions module

0 votes

I'm trying to integrate web3 (using truffle) in a cloud functions module and I keep getting this error:

Error: Invalid JSON RPC response: ""

Here is part of the implementation:

admin.initializeApp(functions.config().firebase);

const db = admin.database();

const provider = new HDWalletProvider(mnemonic, infura link);

const web3 = new Web3(provider);

As Far as I understand, the error indicates that truffle library is unable to establish a connection to the ethereum network. I wonder if this has something to do with deploying this code to firebase.

Thanks in advance.

Oct 17, 2018 in Blockchain by sabby
• 4,390 points

edited Oct 17, 2018 by sabby 1,076 views

1 answer to this question.

0 votes
I had this issue and my problem was that my dev project was on the free "Spark" tier for Firebase. Outgoing network requests in Cloud Functions requires that you are on a paid plan, so I upgraded to the "Blaze" tier which is pay as you go and my web3 cloud functions started working immediately.

Hope this helps.
answered Oct 17, 2018 by Perry
• 17,100 points

Related Questions In Blockchain

0 votes
1 answer

How to access member functions of smart contract using web3?

I have implemented a similar feature and ...READ MORE

answered Aug 13, 2018 in Blockchain by slayer
• 29,370 points
1,561 views
+1 vote
2 answers

Integrating web3 from Metamask: "ReferenceError: window is not defined" error

You can't use MetaMask on server-side because ...READ MORE

answered Oct 10, 2018 in Blockchain by Omkar
• 69,230 points
6,944 views
0 votes
1 answer

UnhandledPromiseRejectionWarning: Insufficient funds error in Ethereum: NodeJS web3

sendSignedTransaction returns a promiEvent onto which you can chain then and catch: web3.eth.sendSignedTransaction('0x' + ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 69,230 points
1,371 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,885 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,401 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,335 views
0 votes
1 answer

How can i read headers of blockchain in multichain?

You could use a recent feature known ...READ MORE

answered Mar 26, 2018 in Blockchain by Perry
• 17,100 points
700 views
+15 votes
5 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP