Ethereum Unity3D Boilerplate Questions

@dgoodrich Iā€™ll update to 1.0.4 and test. Making this a UPM package will mean that all external dependencies such as UniTask can be downloaded separately.

References:




GitHub issue: https://github.com/ethereum-boilerplate/ethereum-unity-boilerplate/issues/42

Has MoralisInterface.cs been moved to the top level of the directory?

Anyway nothing has changed, I still get this error when I use a different app to access a Cloud Function on my Moralis Server instance:

2022-02-11T09:45:47.880Z - Error: Invalid session token
    at Object.getAuthForSessionToken (/moralis-server/lib/Auth.js:114:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Iā€™m also still getting a NullReferenceException when I try to log out, both manually and when it is triggered through Application.quitting.

Long back I was able to use the API Console for a specific user but nowadays it doesnā€™t work either.

This old error did not appear in one project but appeared in another even when both are using .NET Standard 2.0:

D:\dev\Banzan\UltraCore\MoralisWeb3ApiSdk\Moralis\Moralis.WebGL\Moralis.SolanaApi\Client\ApiClient.cs(154,20): error CS0103: The name 'HttpUtility' does not exist in the current context

@vivraan,

Are you comfortable sharing your Cloud Function code?

Thanks,

David

Also, have you posted the cloud function question and code in a forum channel for cloud functions?

No, not yet Iā€™m afraid. I decidedly stuck here since I was usually using Unity for this, and because I suspect itā€™s not a problem with Cloud Functions.

Iā€™ll confirm with my boss just to be sure. Please send me your GitHub/GitLab email address privately.

@nasirs, @SamR, @vivraan, @cuongnm, @jlourie, @YosephKS, @enoonmai, @K00N

I had to release a critical update this afternoon. Authentication now requires server Time be included in the message being signed.

The change was made in the MainMenuScript.cs file of the Demo

    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();
    }

The newest release (v1.0.5) has this patch.

3 Likes

Ah shucks, need to do the whole update process again šŸ„²

Why not just that block of code?

Is it just that code thatā€™s changed? Well in that case, sure!

1 Like

That is it, added code to retrieve the server time and add it to the message being signed. No other changes needed.

i receive UriFormatException from version 1.05 when login using walletconnect via WebGl. version 1.04 working fine. pls help tq

1 Like

Hi @enoonmai. I am having the same problem as it was saving my class ACL as ā€œMaster Key Onlyā€ I set my PublicReadAccess = true and PublicWriteAccess, but I was still getting ā€œMaster Key Onlyā€. Have you figured out the solution for this?

Awesome @dgoodrich :star_struck: :fire:

Hi, thanks for your solution, I able to run photon 2 in WebGL. but i have problem with player swapping controller. when one player in the room, the playercontroller is working, but when second player join the room, the player 1 control player 2 while player 2 control player 1. Do u hav the same problem? TQ

1 Like

You have to verify the authority of the player
Use photonView.isMine to do this
If true, you can use and move the player
If false, you canā€™t
This is the basic logic for multiplayer

1 Like

Would make a lot of sense as a new thread.

I do note receive the same error. Please double check the fields in your MoralisSetup Controller. Look to see that both Server Uri and RPC Node Uri are set from the values on your Moralis Server.
**

**

If this values are set, does the same error happen if you run it in the IDE? If so please copy the text of the exception and post it.

Regards,

David

TQ, missing the Rpc node, all working now

1 Like

where do I find this Rpc Node URI? I have Server URL and AppID, but where is this from?

1 Like

In the Admin Panel of you Moralis Server click on Speedy Nodes:

Then click on the ā€œEndpointsā€ button of the target chain. Choose the URI of the endpoint you want to send Web3 requests to.

Regards,

David