Ethereum Unity3D Boilerplate Questions

Please check out the Cloud Functions doc page for more information about using CLI to deploy Cloud Functions.

@dgoodrich I had posted a comment a while back on YouTube where you introduced the Unity package.

There I’d said this:

I’d really appreciate if the Moralis package was compatible with UPM for convenience. The Example directory could be part of Example Assets deployed once the package is installed. This also makes it easier to clone the project once and simply update by pulling from a stable branch or commit every time a release is available, and having the package included from the Package Manager.

1 Like

I am currently working with Unity to publish to the Asset Store. Once that is done you will be able to use Package Manager to perform updates. It is all a process :slight_smile:

Regards,

David

2 Likes

One more question that popped up is: how do I upload data to Moralis for use in a database, which will be read off by an oracle on a smart contract?

1 Like

You can find sample code to save data to the Moralis Database in the bloilerplat ReadMe here.

If you want an Oracle to read the data you probably want to set up a Cloud Function to front the data.

If I have misunderstood you question please let me know.

Thank you,

David

In my use case, I have a database that I can interact with from the client app and a smart contract.
The client app sends some information to the server, which is then used to update the database and compute a certain reward.
The contract then queries that database, retrieves the amount to reward, and airdrops the given amount of tokens to the client.

It’s not the Moralis.Web3Api that is missing; it’s
Assets/MoralisWeb3ApiSdk/Moralis/Moralis.WebGL/Moralis.Web3Api/Api
that is missing from git (strange that it’s the only one missing?)

1 Like

ah - weird. My apologies I will get that fixed!

@enoonmai,

Thank you for reporting that. Cause was a .gitignore for Android API. This also filtered out the new WebGL API folder. Issue is fixed and checked in.

Regards,

David

awesome thanks! :smile:

1 Like

https://github.com/SamuelAsherRivello/Intro_To_Unity_Crypto/ is public. All sublinks, no.

I’m on “Moralis / Unity3D Asset Package v1.0.2”. Couple questions…

  1. How do you recommend to handle casual internet connectivity? Which method can ask “Is the internet connection to Moralis backend working?” The MoralisInterface.IsLoggedIn() is not an adequate proxy. It returns true when I have zero wifi (which itself is not a bug). But the method name will likely lead to developers’ confusion. Ideally, I’d like a sync method with previous result, async method seeking up-to-date result, and a callback which fires whenever connectivity changes.
  2. Does the API support deletion of custom objects? If so, how? I see much commented out code, so I assume this is not supported yet.
1 Like

Give this a try: Unity - Scripting API: Application.internetReachability (unity3d.com)

@SamR,

Thank you for pointing this out.

For #2 the answer is yes and no. Looking at the code I had an implementation at one point and in one of the many re-writes I failed to re-implement the “Delete” option directly on the object. A miss on my part.

That being said, for now you can call the underlying service:

await MoralisInterface.GetClient().ServiceHub.ObjectService.DeleteAsync([OBJECT], user.sessionToken);

I will create an issue in GitHub to expose the DeleteAsync method on both the Client and the base MoralisObject.

Regards,

David

I have opened issues #13 & #14 in GitHub for this issue.if you want to follow.

@SamR,

For your first question - you helped me find another issue to correct :slight_smile:

I was going to suggest you create a subscription and monitor the close event. However currently when you create a subscription and disable the network it throws an un expected exception.

For now you I would say call MoralisInterface.GetClient().UserFromSession(user.sessionToken); This will re-load the user object from the server, if the internet is available this will return the user object.

I will create an issue in Github for the LiveQuery issue described above.

Regards,

David

That’s an excellent general Unity tip and an adequate workaround. Ideally, the MoralisSDK provides a solution for us — so we have a bool of ‘both internet AND moralis work now?’ not just a bool of ‘internet works now?’.

@dgoodrich the project is missing asmdefs. Should I make a pull request for adding these over?

1 Like

@dgoodrich there’s code in Examples that WalletConnectSharp and WalletConnect.Unity requires. Please move those packages.

There’s also duplicate code in WalletConnectSharp.Unity/Editor and WalletConnectSharp.Unity/EditorTools.

I also found a possible reason for cyclic dependency reference between WalletConnectSharp.Unity and the Moralis folder assuming that asmdefs are defined at the top level of each of those folders: WalletSelectItem is part of the Moralis folder but should technically be in WalletConnectSharp.Unity.

1 Like

The asmdef file is in MoralisWeb3ApiSdk/WalletConnectSharp.Unity/Network/Client

Are you refering to the dependanceis in the Examples\Packages folder?

I will look into this.

Do you see the asmdef file in any folder other than MoralisWeb3ApiSdk/WalletConnectSharp.Unity/Network/Client?