问题
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.
回答1:
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 someone.
来源:https://stackoverflow.com/questions/49181817/integrating-web3-in-cloud-functions-module