Hi, im implementing moralis in a proyect and get this error:
Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading ‘fromWei’),
this is my line of code:
setEthBalance(Moralis.Units.fromWei(result.balance))
Hi, im implementing moralis in a proyect and get this error:
TypeError: Cannot read properties of undefined (reading ‘fromWei’),
this is my line of code:
setEthBalance(Moralis.Units.fromWei(result.balance))
Which version of moralis
/ moralis-v1
are you using? This should be FromWei.
setEthBalance(Moralis.Units.FromWei(result.balance))
“moralis-v1”: “^1.11.0”,
Did you correct to FromWei
?
Same problem with:
setEthBalance(Moralis.Units.FromWei(result.balance))
Full function:
const fetchNativeBalance = async() => {
const result = await Web3Api.account.getNativeBalance({
chain: "cronos testnet",
address: user.get('ethAddress'),
}).catch(e => console.log(e))
if(result.balance) {
setEthBalance(Moralis.Units.FromWei(result.balance))
}
}
You get the same error? How have you imported Moralis
? Which version of react-moralis are you using? It should be 1.4.2 (when used with moralis-v1).
Yes, i get the same error:
TypeError: Cannot read properties of undefined (reading ‘FromWei’)
Import:
import Moralis from "moralis";
json:
"moralis": "^2.4.0",
"moralis-v1": "^1.11.0",
"next": "12.3.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-moralis": "^1.4.2",
Should be from moralis-v1
not moralis
having import Moralis from "moralis-v1";
This works for me, thank u