Hello everyone, I’m experimenting with Unity and Moralis. I need help with GetNativeBalance. My code is not working even though it is a very simple request. I am working with sample scene(introduction). My code is as below and it gives the error in the title.
public async void OnConnectToServer(WCSessionData arg0)
{
NativeBalance bal = await MoralisUnity.Moralis.Web3Api.Account.GetNativeBalance(arg0.accounts[0] , ChainList.eth);
Debug.Log(bal.Balance);
}
When I change my code as below, this is the error;
“ApiException: Moralis must be initialized before use.”
public async void OnConnectToServer(WCSessionData arg0)
{
NativeBalance bal = await
MoralisUnity.Web3Api.MoralisClient.Web3Api.Account.GetNativeBalance(arg0.accounts[0] ,
ChainList.eth);
Debug.Log(bal.Balance);
}
How was the connection established without initializing? I think there is a connection because the address is taken correctly. In fact, this function is called with the Connected event.
what’s the problem?