ethereum - 无法使用 MetaMask 在我的 Dapp 中注入 Web 3 - 请协助
问题描述
我有一个带有以下代码的简单 HTML 文件,试图从 Chrome 连接到我的智能合约。
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
console.log(web3);
} else {
// set the provider you want from Web3.providers
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
使用我的 localhost:8545 代码可以完美运行,但是当我停止 localhost 时,它只是没有通过 MetaMask 插件连接。我尝试了一切,关闭浏览器,退出 MetaMask 并重新登录新页面,重新安装 MetaMask。没有任何效果。我的刷新页面一直在寻找本地主机连接。
解决方案
推荐阅读
- php - 如何忽略 PhpStorm 项目下的特定 phar 文件?
- python - ValueError:检查输入时出错:预期dense_39_input的形状为(6,)但得到的数组形状为(1,)
- c++ - 使用 cout 运算符重载字符串
- javascript - 扩展功能以防止在输入字段内粘贴
- c++ - 错误:无法解析对重载函数的引用
- oracle-golden-gate - ORACLE Golden Gate Classic 相对于源数据库的安装位置
- r - 根据第二列中的值拆分整数,分配新值,然后重新组合成新数据集
- asp.net-core - ASP.NET Core Razor 页面包罗万象的路线
- java - 由于 JDK/JRE 错误而无法运行程序
- sql - 如何将 ElephantSQL 与 TypeORM 连接?