trustwallet / wallet-core

Cross-platform, cross-blockchain wallet library.
https://developer.trustwallet.com/wallet-core
Apache License 2.0
2.86k stars 1.6k forks source link

how to initwasm? I can not find anything related from document #3992

Closed fukemy closed 2 months ago

fukemy commented 2 months ago

Hi all, I am new about wallet-core, I want to use NextJS to integrate with WalletCore, step by step, by following code above:

import { initWasm } from "@trustwallet/wallet-core";
useEffect(() => {
    initWasm().then((WalletCore) => {
      const { CoinType, HexCoding, HDWallet,
        AnyAddress, Derivation, DerivationPath } = WalletCore;
      const mnemonic = "abandon ability able about above absent absorb abstract absurd abuse access accident";
      const wallet = HDWallet.createWithMnemonic(mnemonic, "")
      const address = wallet.getAddressForCoin(CoinType.bitcoin)
      console.log("Bitcoin Address:", address)
    }).catch(error => {
      console.log('initWasp error', error)
    })
  }, [])

I put the file wallet-core.wasm into nextjs build folder, then run it, after run I got this error: initWasp error 2153272 - Exception catching is disabled, this exception cannot be caught. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch

Can someone help?

satoshiotomakan commented 2 months ago

You cannot just copy wallet-core.wasm, please import @trustwallet/wallet-core package

satoshiotomakan commented 2 months ago

Duplicate https://github.com/trustwallet/wallet-core/discussions/3193#discussioncomment-10393910

fukemy commented 2 months ago

I already import @trustwallet/wallet-core for successfull call above method