Initialized, run Web3Api.initialize first

hi, out of the sudden my code does not work anymore. I am receiving the below error:

moralis.js:6313 Uncaught (in promise) Error: Web3Api not initialized, run Web3Api.initialize first
at Function. (moralis.js:6313)
at tryCatch (moralis.js:26893)
at Generator.invoke [as _invoke] (moralis.js:27123)
at Generator.next (moralis.js:26948)
at asyncGeneratorStep (moralis.js:26402)
at _next (moralis.js:26424)
at moralis.js:26431
at new Promise ()
at new Wrapper (moralis.js:31003)
at Function. (moralis.js:26420)
(anonymous) @ moralis.js:6313
tryCatch @ moralis.js:26893
invoke @ moralis.js:27123
(anonymous) @ moralis.js:26948
asyncGeneratorStep @ moralis.js:26402
_next @ moralis.js:26424
(anonymous) @ moralis.js:26431
Wrapper @ moralis.js:31003
(anonymous) @ moralis.js:26420
(anonymous) @ moralis.js:6356
(anonymous) @ moralis.js:6536
tryCatch @ moralis.js:26893
invoke @ moralis.js:27123
(anonymous) @ moralis.js:26948
asyncGeneratorStep @ moralis.js:26402
_next @ moralis.js:26424
(anonymous) @ moralis.js:26431
Wrapper @ moralis.js:31003
(anonymous) @ moralis.js:26420
(anonymous) @ moralis.js:6547
getTransactions @ main.js:36
async function (async)
getTransactions @ main.js:36

2 Likes

what version of Moralis SDK you have? you can get the version with Moralis.CoreManager.get("VERSION")
There were some changes in latest version.

thank you. my version is ‘js0.0.80’

Hey @nani

Please use new init syntax:
https://docs.moralis.io/moralis-server/getting-started/quick-start#initialize-moralis

It will automatically init Web3API

1 Like

thank you @Yomoo. I am currently using the below for the connection to moralis sever:
Moralis.initialize(“LtCAPag9Kl1f9oOtxJ5jr7xV9KbuBJbSklemDqvK”);
Moralis.serverURL = “https://a1zxiyoi7jle.moralishost.com:2053/server”;

do I need to change this?

Yes, you have to use:

Moralis.start({ serverUrl: “https://a1zxiyoi7jle.moralishost.com:2053/server”, appId: “LtCAPag9Kl1f9oOtxJ5jr7xV9KbuBJbSklemDqvK” });

3 Likes

perfect, thank you team. it worked.

the below function does not work. i am receiving below error:

Uncaught (in promise) {code: 141, error: ‘Error: required param address not provided’}
https://a1zxiyoi7jle.moralishost.com:2053/server/functions/getNativeBalance

does this relate to the above problem/change?

function:
getBalances = async() =>{
console.log(‘Get Balances click’);
const rinkebyBalance = await Moralis.Web3API.account.getNativeBalance({ chain: “rinkeby” });

1 Like

yes, it is also related to that change, we will make a fix soon for this

3 Likes

When will this issue be resolved?

1 Like

I would expected to be fixed today, I’ll reply here when is fixed

1 Like

Thanks buddy, really appreciate your help

@Tommy @nani, you can check now

2 Likes

Back and better the 3 depreciated warnings are now gone!

Thank you Moralis team!

thank you @cryptokid but for some reason i am still receiving the below erros if i call the function. not sure if it is me or something else.

Failed to load resource: the server responded with a status of 400 ()

Uncaught (in promise)

  1. Object

  2. code: 141

  3. error: “Error: required param address not provided”

  4. [[Prototype]]: Object

i did a debug, i think the below is still now working:

const ethBalance = await Moralis.Web3API.account.getNativeBalance()

what you see if you run this in browser console: Moralis.CoreManager.get("VERSION")?
you should see: 'js0.0.87'

i get the below version:
‘js0.0.87’

it looks like you also have to use something like window.web3 = await Moralis.enable();

1 Like

yes, now it works. thank you

1 Like