Ethereum Unity3D Boilerplate Questions

Yes the fix did work! This new question is actually what came out due to the validation going through!

Is Moralis Nitro essentially the beta phase for the next stage of improvements which can be accessed starting from the free tier?

Also, I went on Discord and found that the way people were handling string balances was by using Moralis.Units.Token(str, decimals) to convert the string into a BigNumber for use. However, the typescript API marks it as returning a string and not a BigNumber, and somehow even though I have the BigNumber package I’m not able to use new BigNumber(str).

1 Like

Just checked, it looks like the server doesn’t understand what a BigNumber is. Whenever I try to use it with or without importing the type, it throws this error:


  ERROR  || 2022-01-14 05:25:04
Failed running cloud function putWalletWasActiveInInterval for user TMxzXlbYaRxsQ1u3jT0uLXXX with:
  Input: {"signal":true}
  Error: {"message":"Cannot read properties of undefined (reading 'Token')","code":141}
1 Like

The BN library is available through Moralis Web3. Please see this forum question

Regards,

David

1 Like

Somehow it’s not detecting this method!

Could you suggest a relevant thread for my Cloud Code questions?

1 Like

I did not find one that was a good fit so it will best to create a new thread for this.

Regards,

David

New thread for JS SDK issues: Problems with current implementation of Moralis Cloud Code

1 Like

I have followed all the instructions but why when I want to play the demo scene it crashes

Do you mean the Demo scene crashes or Unity3D IDE crashes? Please copy the error that is showing in the log and post it in this thread. The image above does not appear to show the exception.

Thank you,

David

Hey @dgoodrich I received feedback from a dev in the ETHGlobal NFTHack competition on the ResolveAddress API and seems like he gets an error on it:

ApiException: Error calling ResolveAddress: {"code":141,"error":"Invalid function: \"resolveAddress\""}

and his code is like this

Resolve result = MoralisInterface.GetClient().Web3Api.Resolve.ResolveAddress(domain);

Not sure if there’s any problem there or something that he might miss, but if you found something, let me know :raised_hands:

1 Like

@YosephKS,

Can you send me the domain as well? Did the user try this in the admin panel as well?

Thank you,

David

Hey @dgoodrich I am working on a WebGL game. Is it possible to use the web wallets to connect?

1 Like

Hello, you can but it is tricky. The default Wallet Connect / Unity package does not support this so I am working on a custom solution. I am looking at This Project as a solution for us.

Regards,

David

@YosephKS,

Maybe the user needs to update their server?

I ran the example via the Unity SDK:

var result = MoralisInterface.GetClient().Web3Api.Resolve.ResolveAddress("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");
Debug.Log($"{result}");

and result was

{
  "name": "vitalik.eth"
}

as expected.

Regards,

David

1 Like

Ohhh I see cool, sorry didn’t saw you message was taking a bit of break. Seems like you already message the user directly as well :raised_hands:

1 Like

@dgoodrich I’m enjoying SDK v1.0.2.

I would like exactly ONE “Hero” subscription to exist and to live as long as the Unity play session. By default, they last longer. Suggestions?

Perhaps I could call RemoveSubscriptions when unity OnDestroy fires, but that is probably too “late” if called as the session ends. I did not try yet.

For code-separation preference I created class MoralisLiveQueryCallbacksForHero : MoralisLiveQueryCallbacks<Hero> which I don’t believe causes any issues.

I tried to call RemoveSubscriptions before AddSubscription as shown…

MoralisLiveQueryCallbacksForHero callbacks = new MoralisLiveQueryCallbacksForHero();
MoralisQuery<Hero> moralisQuery = MoralisInterface.GetClient().Query<Hero>();
MoralisLiveQueryController.RemoveSubscriptions("Hero");
MoralisLiveQueryController.AddSubscription<Hero>("Hero", moralisQuery, callbacks);

But still get the result per image when the Unity play session starts (for the 5th time in this example)

1 Like

Is the “5” above is the Request Id from the MoralisLiveQueryClient instance? I would guess so since this is the Subscription created message. The RequestID is a static var in the MoralisLiveQueryClient that is only used as an application instance identifier to send to the back end.

Q. What build are you running? If WebGL let me know - nothing below may apply.

Q. Are you seeing multiple Subscription Created messages for a single subscription?

Q. Does

Mean that “Play” is froma cold game start or, the game is still running but reset?

The MoralisLiveQueryController is coded so that when the app closes, it automatically unsubscribes all subscriptions. Like wise, when the app (mainly for mobile) goes to sleep it unsubscribes and then re-subscribes on awake. This is to avoid web-socket errors on mobile caused by the app going to sleep.

Please let me know. I will get a chance to re-try this process this afternoon.

Thank you,

David

I use code from the SDK Examples of…

OnSubscribedEvent += ((requestId) => { Debug.Log($"{Title}: Subscription {requestId} created."); });

Now I see that I had misread the Debug log output. I see now that there is no issue. I withdraw my question. Thanks for the prompt help.

To answer your q’s…

  • I’m targeting standalone Windows
  • The output I’m seeing in a play session is completely captured in the screenshot of my related post
  • I’m using the Unity editor’s ‘Play’ to start a play session and the Unity editor’s ‘Stop’ button to end a play session
1 Like

Hey I apologize if this has been answered already, I have not explored it to much yet. But for some reason the Moralis wallet connector is not loading properly. I’m linking from an android build. Any idea why this would be? I got it to work the first time around but now it just goes to a blank page

1 Like

Do you mean a black screen after you authenticate? If this is the case, did you link all of your scenes in Build Settings?

Does the current WalletConnect API allow using local devnets such as Ganache?

1 Like