1

Hello im try get account balance after signin always send the same error

if (window.walletConnection.getAccountId()) {
  window.account = await near.account(walletConnection.getAccountId());
  window.account.getAccountBalance().then(balance=>{
    console.log(balance)
  }).catch(e =>{
    console.log(e)
  })
}

*TypeError: Cannot read properties of undefined (reading 'storage_amount_per_byte') at Account.getAccountBalance (near-api-js.js:346:78)

UPDATE config:

    const config = {
    nodeUrl: "https://rpc.testnet.near.org",
    deps: {
        keyStore: new nearApi.keyStores.BrowserLocalStorageKeyStore(),
    },
    networkId: 'testnet',
        nodeUrl: 'https://rpc.testnet.near.org',
    contractName: CONTRACT_NAME,
    walletUrl: 'https://wallet.testnet.near.org',
    helperUrl: 'https://helper.testnet.near.org'


};
josedlujan
  • 5,357
  • 2
  • 27
  • 49
  • The code you added in the question looks correct to me. Is it possible to add some more code where you init near (where you write `connect(config)`), and connect to the wallet? I'm not sure, but it may look like the runtime_config isn't set properly on the connection – John Jan 12 '22 at 13:04
  • Maybe this answers your question? https://stackoverflow.com/questions/70677582/function-getaccountbalance-doesnt-work – John Jan 12 '22 at 14:04
  • Hi @John the paste question is my and i dont have the answer yet... i add the config code, do you think something is wrong? – josedlujan Jan 12 '22 at 16:39
  • Hello @jhon thanks for quick answer, try to explain my problem im using only js pure for educational purpose, using import direct on my index.html ` ` and after call near functions – Josue Hernandez Jan 12 '22 at 16:46
  • I don’t think keyStore should be nested into deps in the config. Try to remove deps, and use keyStore directly – John Jan 12 '22 at 22:53
  • Which version of the `near-api-js` are you using? I want to try to set it up using the same config as you. – John Jan 12 '22 at 23:35

0 Answers0