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,350 points

edited Oct 17, 2018 by sabby 125 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,020 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,170 points
85 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
• 67,660 points
695 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
• 67,660 points
225 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
169 views
0 votes
1 answer
0 votes
1 answer

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

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,340 points
88 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,020 points
46 views
+15 votes
5 answers