Ethereum Unity3D Boilerplate Questions

Hi guys, can you tell me how I can call a smart contract (that modify the contract state) from within Unity using the SDK?

Thanks.

2 Likes

Hi, thanks for asking. This is a known issue.
You can use NEthereum with Wallet Connect but only in desktop apps at there moment.

I am working with the Wallet Connect / Unity developer to create a fix that will enable this feature on all platforms.

Regards,

David

1 Like

You can use NEthereum with Wallet Connect but only in desktop apps at there moment.

Is there a doc for this specifically working with Moralis? It would help a lot.

Hello @dgoodrich & Moralis Community!

Great to connect and to learn more about opportunities within the world of Unity and Crypto. I am brand new to the Moralis community. Iā€™ve completed the 3-minute dApp project and given the https://github.com/ethereum-boilerplate/ethereum-unity-boilerplate a full review including publishing and playing with the demo.

I am an American citizen with over 20 years of game development experience. Iā€™m shifting my own passions and experience toward the crypto side of gaming and found your company.

Unity is a rich toolset that is (deservedly) outside of the main crypto tooling pipelines and that is a missed opportunity as crypto+gaming continues its rapid ascent in popularity. Glad to see Moralis leading the way.

Kudos on the great work!

Iā€™ll certainly have more questions and feedback soon.

Some suggestions for the GIT Readme

  • Add instructions for the gameplay. Itā€™s not clear what is and isnā€™t to be expected when hitting the Unity play button
  • Add some context regarding authorization. The docs make many assumptions in general, and thatā€™s ok since its early days, but auth is low-hanging fruit for answering common questions. Something simple is ok for now (e.g. Go get an app (link), do free signup (link), then point the phone at the screen to login).

Thanks again!

-Sam Rivello
Unity Game Development Instructor

Resume | Teaching Portfolio: SamuelAsherRivello.com/contact/

2 Likes

@SamR,

Thank you for the comments. I do plan on creating some more complex examples to showcase more of the Moralis SDK.

Regards,

David

1 Like

Hello Moralis Community!

Having fun with Unity+Crypto including Moralis and working my way through creating robust custom demos. More details to come! https://github.com/SamuelAsherRivello/Intro_To_Unity_Crypto/

2 Likes

Cool - are these live already?

Hi David,
Was just looking to try out the latest changes with the addition of support for webgl but it seems like there are some compile issuesā€¦ maybe the api folder is missing in ā€œAssets/MoralisWeb3ApiSdk/Moralis/Moralis.WebGL/Moralis.Web3Apiā€? (there is a meta file but no folder)

1 Like

Hi. we want to make a game with Unity and integrate with blockchain.

1: in your Youtube channel i just saw 1 video about Unity, did you have a full SDK or API for unity as well as React or other languages?
2: You have a server. What happens when the server shuts down ? so in this case our Dapp is not Dapp! and doesnā€™t work. Right?
3: if you support Unity, what Version is good for working with metamask or other wallets in a game? For example Mobile version or OpenGL version?

1 Like

Hi, justed wanted to ask if Cloud Code support is available via this package.
If not, Iā€™d like to know how to deploy some code to Moralis Cloud since our requirement hinges on it.

1 Like

Sorry you encountered an issue with the new package. Were you using an existing project or a new project? Please let me know. To double check, I created a new project and imported the package. It ran without compile errors.

Some things to check:

  1. Look in the path indicated Assets/MoralisWeb3ApiSdk/Moralis - is the Moralis.Web3Api folder actually missing?
    a) If yes, try re-importing the package (if this is a new project delete the MoralisWeb3ApiSdk folder.first.)
    b) If no, delete the meta file and allow Unity to recreate it.

Please let me know if this helps or not.

Regards,

David

1: in your Youtube channel i just saw 1 video about Unity, did you have a full SDK or API for unity as well as React or other languages?

Yes, the full SDK (other than Plugins - this is coming soon) is available for Unity3D. Moralis also offers the full SDK in JavaScript, React, and React Native.

2: You have a server. What happens when the server shuts down ? so in this case our Dapp is not Dapp! and doesnā€™t work. Right?

Moralis has layers of servers distributed across the globe so a complete outage is very unlikely.

3: if you support Unity, what Version is good for working with metamask or other wallets in a game? For example Mobile version or OpenGL version?

Any version of Unity3D, 2020.3 and newer. The platforms should all work with the same wallets. The SDK utilizes Wallet Connect so any wallet compatible with Wallet connect can be used. That being said we have noticed that Metamask sometimes has issues communicating with Wallet Connect (we do know that Wallet Connect and Metamask are actively working on this). Due to this we usually test with other wallets.

Hope this helps. Please let me know if you have any other questions.

Regards,

David

So far I understand from the code base that I can execute Cloud functions from Unity but I see no means to deploy cloud functions. Maybe I have to use JS for that.

1 Like

Thanks for asking, yes, Moralis Cloud Functions are supported by the oralis / Unity SDK. The newest version of the boilerplate demonstrates this in the TokenListController.cs file.

Here is the code snippet that shows how to call a cloud funtion:

// Field(s) for the cloud function.
IDictionary<string, object> pars = new Dictionary<string, object>();

pars.Add("url", token.Thumbnail);

ResourceResponse resourceResponse = await MoralisInterface.GetClient().Cloud.RunAsync<ResourceResponse>("loadResource", pars);

The code for the Cloud Function being called, ā€œloadResourceā€, is in the Boilerplate README.

Please let me know if you have any other questions.

Regards,

David

1 Like

You can add Cloud functions directly in your Moralis Server or by using the CLI (correct this is Javascript)

Regards,

David

1 Like

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