0

I downloaded my local node on the Monero testnet, specifically I used:

monerod --testnet --db-sync-mode fast --prune-blockchain

After successfully launching the node, I mined some XMR. My intention is to test Monero transactions with the monerojs Javascript library.

Currently on my Monero address I have about 1.5 XMR but when I try to view my balance from the local Javascript console, it always shows me a balance equal to zero.

This is the Javascript code I used:

let wallet = await monerojs.createWalletFull({
    networkType: MoneroNetworkType.TESTNET,
    password: "<MyPass>",
    mnemonic: "<myMnemonic>",
    server: new monerojs.MoneroRpcConnection("http://127.0.0.1:28081"),
    });

const syncResult = await wallet.sync();
console.log('Sync progress:', syncResult);

let account= await wallet.getAccount(0)
  const balance=account.getBalance() // or const balance=parseInt(account.getBalance().toString(), 10)
  console.log("BALANCE:")
  console.log(balance)

//RETURN ME THIS:
BALANCEE
BigInteger { _d: [], _s: 0 }

or

BALANCEE
0

Can someone explain to me if I'm doing the wrong connection to the daemon or some wallet configuration?

2
  • Have you fully synced/scanned the blockchain with your wallet? Your post above doesn't show you have actually done this. See example usage in the tests: src/test/TestMoneroWalletFull.js
    – jtgrassie
    Jun 16 at 2:01
  • I was doing the sync function wrong at the node. Now works. The only thing is that it is very slow to sync the wallet. If I do it via monero-wallet-cli it's much faster
    – AlexCav
    Jun 16 at 9:17

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.