我正在构建一个安卓钱包使用的反应-本机,并试图创建一个帐户使用web3.eth.accounts.create()。这适用于启用了react的本机远程调试器。但是,当我关闭调试器运行相同的代码时,它将停止工作。
这是我的package.json
"cryptico": "^1.0.2",
"native-base": "2.8.0",
"node-libs-browser": "2.1.0",
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-firebase": "^5.2.0",
"react-native-gesture-handler": "^1.0.12",
"react-native-scripts": "1.14.0",
"react-navigation": "^3.0.9",
"socket.io-client": "2.0.4",
"web3": "1.0.0-beta.34"发布于 2019-01-29 19:05:08
我通过使用ethers.js来创建新的电子钱包来修复它。
// this is specifically for react-native
import 'ethers/dist/shims';
import {ethers} from 'ethers';
// to create a ethereum wallet
let randomWallet = ethers.Wallet.createRandom();Web3.js对于react本机来说真的很麻烦
在这里阅读更多信息:https://docs.ethers.io/ethers.js/html/cookbook-react.html#
这是一个专门为反应本机设计的指南。
发布于 2019-01-29 12:28:39
我在使用web3时遇到了问题,所以我转而使用ethers.js。它在RN内部运行得更好,它给了你几乎所有你需要的东西。
https://stackoverflow.com/questions/54420690
复制相似问题