Ethereum Unity3D Boilerplate Questions

Okay I understand this is not a change to any of the core features, just an update to the Examples.

ERROR - ethereum-unity-boilerplate - WEBGL: Websocket.instance.ws.onopen

Hello we are getting an error when we try to test the current sample

Invoking error handler due to

ReferenceError: Runtime is not defined
at WebSocket.instance.ws.onopen (https://d147qom55yq2an.cloudfront.net/Build/Build2022.framework.js.br:3:58138)

PD: I have not made any changes to the code, I just put the parameters of my moralis server and compiled the game.

We are using

2 Likes

Unity version: 2021.2.4f1
Build platform: WebGL

versions

1 Like

Rest of Details for this issue

1 Like

Thank you for letting me know. Looks like a few people are seeing the same with that Unity version.

On the github repo Issue #48 has been opened to track this.

What is the Unity Version who you is using?

1 Like

2020.3.26.

The issue with 2021.x.x appears to be related to the jslib that WalletConnect is using. I have been trying some adjustments to see if I can fix it. I just do not want to break it for the current Unity version.

Hi !
I’m on v1.0.5 and unity 2020.3.23
This is my WalletConnectHandler method (having changed anything):

public async void WalletConnectHandler(WCSessionData data)
    {
        Debug.Log("Wallet connection received");
        // Extract wallet address from the Wallet Connect Session data object.
        string address = data.accounts[0].ToLower();
        string appId = MoralisInterface.GetClient().ApplicationId;
        long serverTime = 0;

        // Retrieve server time from Moralis Server for message signature
        Dictionary<string, object> serverTimeResponse = await MoralisInterface.GetClient().Cloud.RunAsync<Dictionary<string, object>>("getServerTime", new Dictionary<string, object>());

        if (serverTimeResponse == null || !serverTimeResponse.ContainsKey("dateTime") ||
            !long.TryParse(serverTimeResponse["dateTime"].ToString(), out serverTime))
        {
            Debug.Log("Failed to retrieve server time from Moralis Server!");
        }

        Debug.Log($"Sending sign request for {address} ...");

        string signMessage = $"Moralis Authentication\n\nId: {appId}:{serverTime}";
        string response = await walletConnect.Session.EthPersonalSign(address, signMessage);

        Debug.Log($"Signature {response} for {address} was returned.");

        // Create moralis auth data from message signing response.
        Dictionary<string, object> authData = new Dictionary<string, object> { { "id", address }, { "signature", response }, { "data", signMessage } };

        Debug.Log("Logging in user.");

        // Attempt to login user.
        MoralisUser user = await MoralisInterface.LogInAsync(authData);

        if (user != null)
        {
            Debug.Log($"User {user.username} logged in successfully. ");
        }
        else
        {
            Debug.Log("User login failed.");
        }

        HideWalletSelection();
    }

here is the full log screenshot :

1 Like

After you do a login in attempt are there any errors in the Log on your Moralis server?

This is a part of the error log on the server side

okay - what is the version of you moralis server in admin panel?

I think is 0.0.345.

weird, that is latest …
The cloud function is working, I just did a login

Try restarting your Moralis server.

Just tried and it doesnt change anything, still getting the same error.

1 Like

Okay. I cannot reproduce.

Please grab a TEXT copy of the server error from this morning. I will send it to someone on the server team.

okay…

This is the error log since i restarted the server, if that’s of any help

1 Like

That is not showing any errors.

Have you tried to login again since restarting?

Yes there is no error in the log now… But I still can’t connect. Same error at the same moment

1 Like

Is there any demo available to create multiplayer games? I’m a newbie and am unable to get any leads :frowning:

1 Like

Something changed then which hopefully is good. Since you do not see the error in the log please re-capture and re-post the unity debug logs from user not authenticated to the error.

Thank you!