Integrating web3 in cloud functions module

一个人想着一个人 提交于 2019-12-11 04:35:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!