React Nativethis。'f_createWallet'不是函数

问题描述 投票:0回答:1

import bip39 from 'react-native-bip39';
import bip32 from 'bip32';
import ethUtil from 'ethereumjs-util';
//    import { ethers } from 'ethers';
//    import { randomBytes } from 'react-native-randombytes'


export class CreateWalletScreen extends Component {
  constructor(props) {
    super(props);

    this.state = {
        mnemonic: null,
        loading: false
    }
}

componentDidMount = () => {
    bip39.generateMnemonic().then(mnemonic => {
        this.setState({ mnemonic })
    });
}


_createWallet = async () => {
  const seed = bip39.mnemonicToSeed(this.state.mnemonic);
  const root = bip32.fromSeedSync(seed);
  const xPrivKey = root.derivePath("m/44'/60'/0'/0/0");
  const privKey = xPrivKey.privateKey.toString('hex');
  let address = ethUtil.pubToAddress(xPrivKey.publicKey, true).toString('hex');
  address = ethUtil.toChecksumAddress(address).toString('hex');
  alert(address);
}


    render(){
        return(
        
        ...
        <Button onPress={() => 
        this.createWallet()} />
        ...
        
        )}

“ react-native-bip39”:“ ^ 2.3.0”,“ bip32”:“ ^ 2.0.5”,

错误

enter image description here

由于我是初学者,所以我正在制作加密钱包。

使用bip库。

按下按钮应显示地址。

但是我有麻烦。该死

如果您帮助我,人类和平将会来临。

plz ...


新错误

enter image description here

javascript react-native ethereum bitcoin cryptojs
1个回答
0
投票

您的函数必须具有相同的调用名称:

© www.soinside.com 2019 - 2024. All rights reserved.