0

i'm trying to make a wallet in react native using ethers.js, but when i'm trying to call the function createRandom, to generate a secure random seed the application gets crashed.

this is the code, i'm using this in a react Context but also when i just the function Wallet.createRandom(), it also gets stoped.

const initWallet = async () => {

    console.log( wallet.currAccount )

    if ( !wallet.currAccount ) {

        
        try {

            const account = ethers.Wallet.createRandom()

            const encryptAccount = await account.encrypt( password )


            const assets: Assets = {
                1: [TokenItems[0]]
            }

            dispatch({ 
                type: 'create_account', 
                payload: { name: 'Account 1', wallet: encryptAccount, assets }
            })

            console.log( wallet.currAccount )
            
        } catch (error) {

            console.log( error )

        }


    }

Does anyone know why this happen?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.