Ethereum Unity3D Boilerplate Questions

I will re-check this code

	// Included Method - Throws "NullReferenceException: Object reference not set to an instance of an object"
	//await moralisClient.DeleteAsync(heroToDelete);

My unit test (on the main SDK project ) passes so I need to debug this live.

Regards,

David

Hello, not yet. This is going to be a big change and may be a while. For now the QR code that Wallet Connect uses is the only work around for now.

Regards,

David

Please elaborate on

Do you mean loading 3D models like the one I attached to the Mug NFT? That I am working on as part of an expanded demo.

David

Very cool. I am working on a demo that will show how to programmatically load the unity_prefab from the mug NFT.

1 Like

You are correct and I have this in my sights as it is true for most, if not all of the Web3API. I need to open this as an issue on gitbhub as my top priority for this week. When I wrote the fix for the WebGL version of the Web3API I made the API calls async. I just need to go back and do the same for the regular Web3API.

Regards,

David

1 Like

Please make this repo UPM compatible so that updates donā€™t break existing code samples.

I like the approach of using a Git URL better than using the Asset Store. That way I can more easily connect my existing UPM infrastructure and I donā€™t have to download the SDK on every single project I work on, instead either referring to the Git repo or a local clone.

Until this change is made I will eschew downloading .unitypackages of new versions because reworking the updates in my private UPM package will be cumbersome. 1.0.2 is safely providing me the functionality I need so far, with some local modifications.

UPM packages also support downloadable examples, and even if not a separate Examples repo is a welcome measure, as it can also use UPM integration succinctly.

1 Like

Hi @dgoodrich seem like i missed some fields in request header.
How should i added these fields? I canā€™t find this information in readme doc.

1 Like

Which headers are missing for you? The required headers should be added automatically. Do you have a github repo with you code?

@dgoodrich Excellent work on everything.

Per # of git repos, I feel like less repos will allow for more rapid development (on your end) and I feel like more repos is a good goal for eventual separation of concerns. Maybe that goal can come closer to SDK v1.0. Iā€™d rather have your team work more rapidly at this stage. I vote for just one repo for now.

A suggested structure is for one repo to contain files only inā€¦

  1. \Assets\3rdParty\Moralis\MoralisWeb3ApiSdk
  2. \Assets\3rdParty\Moralis\MoralisWeb3ApiSdkExamples

Where 2 depends on 1ā€¦ and 1 depends on nothing. The structure suggested will help teams update more smoothly and production teams ditch the examples after importing each new update of the repo as you mature the product.

I havenā€™t dug deep, but I think that the repo currently depends on TextMeshPro. I think that is an unnecessary complication. If one day you include ā€˜shippable quality UIā€™ then yes TextMeshPro is a really good improvement to the published result. But for now, itā€™s a hassle to have (any such) dependencies. We may be over the hump (in the year 2022 with Unity 2021), but historically its a NIGHTMARE when a production project is on one version of TextMeshPro and some 3rd party package (e.g. Moralis) has another version (newer or older) of TextMeshPro.

1 Like

@dgoodrich Iā€™m working on a repo of academic examples showcasing the latest MoralisSDK. In the interest of limited time, I may choose not to cover EVERY topic.

Iā€™m prioritizing showing off the ā€œFundamentalsā€ plus ā€œWhat is the coolest!ā€. :slight_smile:

Iā€™d like your adviceā€¦

  1. Iā€™ve covered the blue-checks here per #1 + storage. Of the categories of #2 - #7, how would you prioritize the importance of each? (Fictional example; 2 is most important then 7 then 3, 4, 5,ā€¦)
  2. Below each of the categories #2 - #7 which (one?) subcategory is the most important? (Fictional example; under #3, GetNFT is most important, under #4 GetPairReserves is the most important).
  3. Are there important things missing from the pic that are suggested priorities? For example, Nethereum ( I donā€™t know what that is yet. Still learning :slight_smile: )
  4. I remember doing the non-unity demo of Moralis and there was a demo of making a contract, putting it on the server, and calling it. Which item in the pic is related to doing that? Pardon my noob-ness :slight_smile:

Maybe there are not easy answers to my questions, thatā€™s ok. Your answers will help will point me in the right direction anywaysā€¦

1 Like

I think what you are doing is very cool. If you have a press release, etc. with links to your courses I would like to post it in our internal forum for the team to see.

I tried to answer your questions, beware, there is a lot expressed here that is opinion :slight_smile:

For Web3Api, Once you know how to use one, you can use them all. #2 Chains is an enum and is used by many of the other calls. I think that #3 Account and #7 Token have the most utility in games. This is a personal opinion and will highly depend on the goals of the game.

From the view point of games, and again this is opinion,
#3 The first three operations could have use in most NFT based games.
#4 I see almost no use for this endpoint in most games. An exception would be a trading game, a long term race to see who can make the best trades, etc. Another exception would be games creatd to teach Defi, similar to my previous examples.
#5 The last two could have some use in gaming depending on the goals of the game. I do not personally see much gaming use for the other operation sin this endpoint.
#6 Could possibly be used, I am not sure but possibly to make it easy for someone to transfer an asset to another account. This would allow the user to enter an address like xactant.crypto instead of the hex address.
#7 I can see that many / most of the operations in this endpoint could be used to enhance token / NFT use in a game.

I put these two together for the simple reason that to create a contract from the game would require Nethereum. Nethereum is the best known (and as far I know) the most reliable .NET Ethereum RPC wrapper currently available. If you have looked at running an Ethereum node, RPC commands are what you use to control and communicate with a node. Nodes (such as the Moralis Speedy Nodes) expose a public API for RPC command calls. This is what wallets use to communicate to a node.

You can use Nethereum to make any RPC supported call to an Ethereum Node.

My opinion and recommendation is to use it only for making calls that write to the chain, what I refer to as state change calls. Most communication with the chain is reading data. In the case of reads, the Moralis Web3Api is faster and more efficient than using Nethereum since it is against an indexed data set and allow data paging and block range searches. (I think Nethereum also supports block ranges searches but need to check that).

Hopefully this helps!

David

Creating a contract from a game is expensive in resources (gas, time, etc.). If someone is minting ERC721 NFTs, creating a contract on the fly could be argued for. Personnaly I like using ERC1155 NFT contracts as this standard was especially written to support using tokens and NFTs in games. For th updated 1.0.3 release I used an 1155 contract and a proxy contract. I minted the demo NFT set via the proxy making the proxy the owner of all (it also enforces the rules of distribution). Since the NFTs are pre-minited the only cost to the user for claiming an NFT is the gas for transfer - on Polygon this is tenths of a cent. Minting an ERC721 NFT for the same asset would cost each user a little of $1.00 on Polygon (on Ethereum Main-net this cost to mint an ERC721 is currently around $40-$50 or more)

1 Like

I cant get the unity boilerplate to run on the rinkeby testnet. I changed the chain ids to 4, Im not sure if theres anything else needed or if this is available to do yet? Please help

1 Like

Hi David, just seeing your message now. No I have not, where do I claim it? Hopefully itā€™s a Moralis Mage haha.

I came across one method for integrating into VR from a channel called FusedVR. Basically he was setting up a way where basically you prompted with a link to WalletConnect via email. So you would sign in via email. Could also work with MetaMask. It looked like a pretty cool way to interface from a headset.

1 Like

Yes
iā€™ll just keep checking github for update

1 Like

This is a non-issue with UPM. Just refer to the package depending on com.unity.textmeshpro and youā€™re golden.

1 Like

Hello, can you be more specific about what is happening with your application? The demo should run out of the box without a chain connection - as long as you authenticate with a wallet.

You would set the chain for Web3API calls and Web3 (Nethereum calls).

Please text copy (screen shot can cut off information) the exception you are receiving and I will take a look.

Regards,

David

Hi! you claim the mug by setting up an account in your wallet to the Polygon / Mumbai chain and use the Polygon faucet to get some test matic, download and run the demo. slay the orcs and bash the chest until it opens. The mug is inside. Click on it and immediately check your wallet. You should have a message asking permission to execute the transfer to your account.

@Ashu-specs, you can also do a search for ā€œUnity3D programmatically load prefabā€ and you will find several examples.

1 Like

Hello @dgoodrich, is there a way to authentificate an unique NFT in Unity ?
I understand that, its possible to read all the NFT of a wallet from Unity, but my question is how to notificate unity that a CERTAIN NFT is in the wallet of the user ?
Big thankā€™s !!

1 Like

I do this in the new demo (released late Friday).

If you know the contract and the TokenId of the NFT, yes you can. Here is the code from the demo (in the AwardableController.cs file):

            try
            {
#if UNITY_WEBGL
                NftOwnerCollection noc =
                    await MoralisInterface.GetClient().Web3Api.Account.GetNFTsForContract(addr.ToLower(),
                    AwardContractAddress,
                    ChainList.mumbai);
#else
                NftOwnerCollection noc =
                    MoralisInterface.GetClient().Web3Api.Account.GetNFTsForContract(addr.ToLower(),
                    AwardContractAddress,
                    ChainList.mumbai);
#endif
                IEnumerable<NftOwner> ownership = from n in noc.Result
                                                  where n.TokenId.Equals(NftTokenId.ToString())
                                                  select n;

                if (ownership != null && ownership.Count() > 0)
                {
                    isOwned = true;
                    // Hide the NFT Game object since it is already owned.
                    transform.gameObject.SetActive(false);
                }
            }
            catch (Exception exp)
            {
                Debug.LogError(exp.Message);
            }
        }

NOTE: After next release, the pre-processor switch here may not be necessary.

Regards,

David