Ethereum unity boilerplate

Yeeahhh dgoodrich​:rocket::rocket::rocket::rocket::+1::+1::+1::+1:

1 Like

Thanks for the update David, will definitely check it out.

Regards,
Kamille

1 Like

Great! Thank you, letsgoo!

1 Like

Hey David,
I’m getting another round of 999+ errors. What packages are you using? When i used Nuget Nethereum.web3 package the errors went down to under 20 but the game demo still won’t run, I am unable to edit the moraliscontroller script. Also using Nuget it seems the newtonsoft.json package is incompatible with Nethereum.web3 package

Regards,
Kamille

1 Like

Ok got it down to 4 errors, basically Nethereum from Nuget has same file name as moralis DLL file, i’m not sure how to resolve this as changing the name just creates more errors. Thoughts? Newtonsoft.json automatically installs under Nethereum.web3 package, so no need for another package, which was the cause of error previously.

1 Like

Another update, got the 1.03 package finally working. You just need newtonsoft.json from nuget to get it running, nethereum.web3 package will clash with the files in moralis 1.03 package. Also have to enable unsafe code as per the readme files.
You can get nuget for unity here:


Good luck frens :slight_smile:
1 Like

@Kamille,

Sorry you had some issues running the demo.

If you have the issue in the future where you cannot open a script from the IDE right click in the assets folder and select “Open C# Project”.

Feel free to replace anything above the “Moralis” folder.

Regards,

David

Release 1.0.3

Hello sir @dgoodrich hope you good!
:mechanical_arm:
Tested new repo, writing feedback finally. see a lot of updates there. Without any errors working fine and more management now in the Demo scene.
The questions are,
im building WebGL, setting up in Players settings - WebGL Default template resolution
While checking on Local and Network Host i see only 1 interpretation of scenes. I mean only this QR code appears.

  1. Where and how i can change settings to work like WalletConnect pop-up on mobilephones? Though it should be automatically changing while you using different devices, no?

in the codes checked several new components you added, something tells me that it is necessary to investigate there components which are switching this ios android desktop menu appearing…

  1. Is it possible to set this switching automatically while you using dif-nt devices on the website for example? I mean responsive dimensions of the screen should change this funcitons appearing of the menu

Btw found some Easter Eggs (mug), thats dope too.
:egg:

Sincerely,
~SpacyLion~

1 Like

@dgoodrich

SDK allowed me to login on Desktop just fine but mobile seems to be having issues

  1. iOS app didn’t detected WalletConnect only shows QR code. Shouldn’t the SDK have opened up WalletConnect menu without additional configuration?
  2. Seems like something is missing. Have you tested the SDK on a clean install? If so, Can you share screenshots or a video walking us through how to configure iOS & Android.
  3. Did you change the implementation? If so, Please provide detailed tutorial

Thanks David!

2 Likes

The default for this is to now use Wallet Connect which for WebGL shows the QRCodelike desk top. I have a feature request for make WebGL use Web-Browser like a normal web application. This is going to take some time though.

You could try to use Moralis Connect for WebGL. In the Demo, post this in MainMenuScript.cs in the Play() method after the pre-processor check for iOS and Android Give this a try:

#elif UNITY_WEB_GL
            await LoginViaConnectionPage();

Post this in before the #else pre-processor statement.

It should switch automatically based on build type.

Regards,

David

For iOS make sure you have selected the wallets you want to display:


You could also use Moralis Connect. To use Moralis Wallet Connect open the MainMenuList.cs and find the Play() method. Find the UNITY_IOS and UNITY_ANDROID comment out the androidMenu.SetActive(true); and iosMenu.SetActive(true); and uncomment the two await LoginViaConnectionPage(); lines.

Yes one of the changes was the integrating the Wallet connect update that fixed it’s Mobile interface. This was really needed for the Nethereum integration. I did check it and, to make sure, just ran a clean build and deployed to Android and it worked as expected. I will do the same again for iOS in a bit (this takes longer to setup).

Thank you for the feedback, again i will double check iOS as well and report back but it did work when I tested it before deploying the changes.

Let me know if you still have difficulty with iOS.

Regards,

David

I did just re-run a clean install and build to Android. I deployed and the Wallet Connect interface did automatically bring up my imToken wallet on my Android.

Got it, will make a try this!

@dgoodrich

David,

We followed your instructions but there seems to be a problem with the standard flow. First off, why are we required to open up the browser to use WalletConnect? We should be able to do the following flow upon login

Connect With Wallet (button) > Select the wallet app > CONFIRM > APPROVE/SIGN

But it doesn’t allow me to do this flow. In fact, I can only SIGN transaction if I choose to “Open in Browser”.

Look at my videos

https://youtu.be/NnUetyRpZFQ

https://youtu.be/0ncFTJpO38c

Thanks for all your help. We are almost done David!

2 Likes

@dgoodrich

David, I wasn’t clear before. Why can’t you have this flow?

Connect With Wallet (button) > Select the wallet app > CONFIRM > APPROVE/SIGN

I’m stuck having to verify inside the browser. I have to press connect twice… I only want to see walletconnect once and then press connect. Once i press connect, we want the native wallet app we select to open. We want to confirm & approve inside the wallet app which approves the trusted platform and signs in.

Walletconnect shouldn’t need to open in a browser. Is this your intent with this SDK? If I have a native application, then the process should behave like a native application… Including walletconnect.

I’m expecting the login/walletconnect to behave like this native boilerplate from Moralis

Look at the login process

Thanks for your work!

1 Like

@Mamba,

With the latest release, in Mobile (if built for iOS or Android) it should open the wallet app. For Android it opens the wallet directly, unless you have more than one installed in which case you choose first. In iOS you (the dev) need to select which wallets to display (this is because there are over 100 and if you do not filter Wallet Connect tries to load all which takes a long time). Once you build for iOS it should show you the wallets you choose at build time. Once you click on one of those it should open the wallet directly.

The previous versions (1.0.0 - 1.0.2) did show the browser since Wallet Connect had an issue in mobile.

Regards,

David

David,

The transaction confirm/signature doesn’t come up when it open right into the wallet app.

I noticed I didn’t attach the right video before.

Please tell me if this works

You’ll notice the wallet is opened (that’s correct).

But the TRUSTED APPLICATION message to Confirm & SIGN/APPROVE

Thoughts?

1 Like

@dgoodrich

David,

We have a set of TRIGGERS/EVENTS that need to help understanding how to implement them in our game. Can you please inform me as to where I would handle these scenarios WHILE PLAYING in the game

NFTs

  1. The user would like to Purchase, Sell, Transfer, Claim, Award an NFT inside of an Native Game App

  2. Player inside game would like to use an NFT inside game. Maybe the NFT grants certain abilities to the user. How would we do this?

  3. How does a user VIEW all the NFTs from multiple wallets at the same time (globally)?

TOKENS REWARDS & PRIZES

  1. Award tournament WINNER with prize (split the POT between 1st 2nd & 3rd place). Want to be able to sent token prize to them. How would I get the game to understand x amount of tokens needs to be sent to users.

FUNDS & FEES

  1. Player needs to add more in game currency from their crypto wallet. How do we trigger this event?

  2. Collect Tournament entry fee

  3. How do we check balance

  4. How do we check for balances of multiple wallets at the same time (globally)?

WALLETS

  1. How do we link multiple wallets to the users profile in order to CRUD all wallets at the same time (globally)?

OTHER FUNCTIONS & EVENTS

  1. Trigger X amount of Tokens to be gifted to a player if they accomplished a Mission.

  2. If a player achieved a certain high score

  3. If a player beats a level in a certain amount of TIME. System needs to Recognize that event happen and then Awards user with TOKEN & or NFTs for accomplishment.

——————————————-

From what’s I’ve read, these are usually supposed to be coded into the ABI file. If that’s the case. Where do I find the ABI file to edit it?

I also read that with Moralis this is much easier. So if that’s the case how would I use Moralis to accomplish what I’m trying to do above? If I am awarding a user with a Prize (NFT or TOKENS). Do I need to store my NFTs inside Moralis? If so where?

Your help is always appreciated!

Thanks David

2 Likes

Ah okay, yes this is a normal flow for Mobile Wallet apps. You approve, slide back to your app. It might hesitate a second or two but should navigate back to the wallet with the signature. You sign and then need to slide back to your app.

The second issue you are having is wallet Connect / Metamask Mobile Wallet interaction. We have seen this even with React Native. The Wallet Connect project says they are working with MetaMask to correct this. Please try a different mobile wallet. I use imToken wallet and Trust wallet (note: trust does not allow test nets or custom node connections)

You will need to call the Web3Api MoralisInterface.GetClient().Web3Api.Account.getNfts for each of the chains you want to show NFTs for.

For Multiple addresses you would need to require the user provide all of their addresses to you and then loop through the address.

That is a function of your contract / game logic. It will depend on many factors that are unique to each game.

These questions all have to do with your unique game logic.

Triggering would be handled by in game events based on specific game conditions - what these are is different from game to game.

To collect fees use the Web3.SendTransactionAndWaitForReceiptAsync method. The MoralisInterface provides one version. If you use the Web3 object directly there are several overrides for this method.

Checking for balances is done vis Web3Api, the Account endpoint.

To check multiple balances means two things - cross chain and different address - see my first answer above.

I am not sure this is possible. Transactions that change state (contract state updates, transfers, minting, etc. Require interaction with the individual wallets.

For read operations you can use Web3Api. For multiple address see my first answer above.

These questions all have to do with your specific game logic and can differ from game to game.

When you create your contract (Remix, HardHat, etc.) and compile it the ABI is created. If there is a third party contract you are interacting with please see any documentation provided by the owners of that contract, they should publish anything that is meant to be used publically.

NFTs are stored on contract but NFT Metadata is stored externally, usually on IPFS. Please see the ERC721 standard and ERC1155 standard for more information about NFT metadata.

You can choose to store stats or other info about user’s and their NFTs or your game’s NFTs on the Moralis database. Most of the information you need for these though can be easily accessed via Moralis Web3Api.

Moralis saves a lot of time with server functions and everything related to reading, parsing, and searching chain data. Hopefully what I have provided above gives a good place to start. The demoscene of the boilerplate provides examples for reading Token and wallet balances (TokenListController.cs, WalletBalanace.cs) and searching ownership for specific NFTs. It also demos how to arawd and NFT (AwardableController.cs). There are a lot of videos on youtube that take you step by step how to create games and interact with the Moralis Web3Api for balanaces, tokens, NFTs, executing read functions against contracts, working with IPFS, etc. Please the the Moralis Web3 channel.

Always happy to help with questions about Morlais and the Moralis / Unity SDK.

Regards,

David