react-native - 来自 infura 测试网的错误在 react-native 应用程序中为空
问题描述
我用它从一个连接到infura rospten react-native mobile app
:
const url = 'https://ropsten.infura.io/v3/xxx';
this.web3 = new Web3(new Web3.providers.HttpProvider(url))
当我打电话给合同时,我得到:
Error: Invalid JSON RPC response: ""]
为什么错误为空?
使用相同的方法连接到本地 ganache,它就可以工作了。
是因为授权还是网络配置?
解决方案
您需要/v3
从 URL 中删除该部分
兑换
const url = 'https://ropsten.infura.io/v3/xxx';
至:
const url = 'https://ropsten.infura.io/xxx';
此外,您是否在连接到 infura 之前签署了交易。在提出任何交易请求之前,您需要为地址签署交易。您可以使用HD-wallet-provider并使用在您创建帐户期间提供给您的助记符。
推荐阅读
- perl - Perl 词法分析器:为什么在 <=><=><=> 的上下文中使用 "<=>" eq "="?
- typescript - 在角度 6 中设置 http 标头获取对 oxford api 的请求
- ruby-on-rails - Rails 事务启动钩子
- javascript - 需要帮助在 REST api 的 GET 函数中将 json 数据写入 json 文件
- reactjs - 我想使用与 ant design 的反应来验证密码
- python - Matplotlib 命令不起作用
- internet-explorer - 卡引导程序 4.1 在 Internet Explorer 中不起作用
- android - 强制页面加载到 webview 中,而不是外部浏览器保持低 API lvl
- python - 无法在 Windows 10 上的 Anaconda 3.6 中导入张量流
- python - windows平台上python 3中从.ui到.py的转换