I can connect to my wallet and authenticate just fine but it doesnt display my ETH in the modal dialog in unity. Im trying to connect using the rinkeby test network, it displays my address correctly but not my ETH balance or anything else related to my rinkeby testnet account.
Make sure you are pre-setting or programmatically setting chain id in the Wallet Balance Controller This value default to eth Main net.
Here are the chain ids:
public enum ChainList
{
eth = 0x1,
ropsten = 0x3,
rinkeby = 0x4,
goerli = 0x5,
kovan = 0x2a,
polygon = 0x89,
mumbai = 0x13881,
bsc = 0x38,
bsc_testnet = 0x61,
avalanche = 0xa86a,
avalanche_testnet = 0xa869,
fantom = 0xfa
};
Hope this helps,
David
Ahhh that did it! Thanks!
Hi, will u going to release multiplayer webgl? tq
Hi David,
Iāve been trying to mint a token and have some questions / feedback:
-
After I log in using wallet connect, for subsequent logins Moralis will say āUser is already logged inā. However, wallet connect will connect and call the callback (WalletConnectHandler) and create a signing request to log into moralisā¦ I assume this is not necessary?
-
I tried calling my mint function using:
var cts = new CancellationTokenSource();
var receipt = await myMintFunction.SendTransactionAndWaitForReceiptAsync(addr, cts, new object[] { });
//Debug.Log($"Receipt: {receipt}");
But this doesnāt seem to workā¦might be that metamask + walletconnect was just being wonky
- When I tried calling my mint function with:
var receipt = await MoralisInterface.SendTransactionAndWaitForReceiptAsync(
myContractKey, "polygon", "mint", addr, new HexBigInteger(0), new HexBigInteger(0), null);
Debug.Log($"Receipt: {receipt}");
The transaction got to my metamask wallet, BUT:
- It didnāt care that I was connected to the wrong network (mainnet instead of polygon)
- When I rejected it, the code in SendTransactionAndWaitForReceiptAsync just prints out an errorā¦ it should throw an exception as well so we can handle the error
- Thereās no API for using a cancellation token when using this method
- When I switched my metamask wallet to use polygon, the gas estimation would not resolve - could be a problem with recent changes to Polygon / EIP 1559?
- The metamask-on-mobile-device flow is really slow! Itās not the greatest user experience. I know that there isināt really anything that can be done about that ( I think you are working on a alternate flow for WebGL builds that uses browser extension wallets?). I was thinking another possible alternative would be to use āmanagedā wallets that could be generated for the user, since nethereum has that capability. (I think?)
Anyhow, just some feedback. I will keep trying to find fixes or workarounds for these issues!
Kind Regards
Update: I was able to get my mint transaction to go through after a bunch of attempts!
I will probably release a demo at sometime. The current release has the tools you need for multiplayer games. Investigate Live Queries in the docs. Ivan also created a basic demo. Though his is in Javascript, the .NET SDK has the same functionality.
This is a factor of Wallet Connect - W.C. stores a session in the game
s user preferences. If you do not revoke the session it persists so that when you restart, even if you think you are not conencted to your wallet W.C. will try to re-establish. Take a look at the Quit() function the the MainMenuScript.cs file. This demos how to sign out of both Moralis and more importantly, W.C.
The first does not work for a writable call since it is not sending gas (or when needed value). The second does. See the example in the demo in the AwardableController.cs file. I supplied a function that wraps the function call but requires gas.
Not knowing which network the user is attached to is an issue that is universal. I need to re-examine the W.C. response to see if anything indicates which chain the wallet is connected to.
For the wrapped call (the second you made) I do return a tuple that indicates success and contains either the result or the error message. My personal preference is to bubble up exceptions but I received a lot of negative feedback about doing this elsewhere in the code. So, with the wrappers I have tried to include a success indicator with payload and msg.
The Function SendTransactionAndAwaitForReceiptAsync does have an override that accepts Cancellation token, I did not expose this in the wrapper. I will update the wrapper to expose this.
You may be right. I ran into the same issue. I originally wrote the demo to call Function.CalculateGas but it always failed - delayed release of the update over a day because of trying to get past this. Finally for sake of the demo I set gas manually. I will add some notes to the demo about how to do this properly.
I feel your pain and agree. One immediate alternative is to look at the MainMenuScrupt.cs file in the Play() method:
#if UNITY_ANDROID
// By pass noraml Wallet Connect for now.
androidMenu.SetActive(true);
// Use Moralis Connect page for authentication as we work to make the Wallet
// Connect experience better.
//await LoginViaConnectionPage();
#elif UNITY_IOS
// By pass noraml Wallet Connect for now.
iosMenu.SetActive(true);
// Use Moralis Connect page for authentication as we work to make the Wallet
// Connect experience better.
//await LoginViaConnectionPage();
#else
Comment out the Menu.SetActive line and uncomment the await LoginViaConnectionPage();
line. Instead of using the mobile W.C. code this will bring up the MoralisConnect webapp. It is faster - however you cannot use this method with Nethereum (We may change depending on W.C. ).
We had the conversation in house back in October about creating a managed Wallet but consensus was that it would limit users since they would need to transfer funds, paying gas and managing another wallet. Additionally the issues of securely maintaining private keys, across multiple platforms is daunting. Is it possible we will come back to this sometime in the future? Yes, but I do not know when.
Thank you for the feedback.
Regards,
David
Thanks much! Iāll dig into this feedback soon.
Hi !
I installed Metamask and I tried to authentificate myself with the QR code in the Unity demo.
For mumbai itās working ! But when I change the RPC url to avalanche testnet network in MoralisSetup component, and switch my Wallet too, i canāt authentificate.
Do you have the same issue or itās a problem on my side ?
Thanks a lot!!
I will give this a try though it should not matter for authentication.
Oh, and for clarification when you say it will not authenticate what do you mean? Just making sure you had opened the app and āQuitā so that you were logged out, esp. for Wallet Connect. If you do not log out, Wallet Connect keeps a session record and will try to use that regardless of what your wallet is. Can be very frustrating. I have run into this before so I may add code to the Example to auto log out of W.C.
I will try Avalanche and see what happens ā¦
I was able to authenticate using an avalanche wallet (I used imToken wallet with an account set to Avalanche Mainnet).
I restarted the game, and started by authentificate Avalanche Testnet first : I work ! Thankās you @dgoodrich
Hello, I just came across the Metaversesdk / web3unity boilerplate. How do i make land blocks and avatars (nfts) and connect them? if that makes senseā¦ if not, please let me know. Also, could this be used for a private blockchain on the ETH network?
Thanks in advance.
Take a look at the Example, esp. AwardableController.cs - this file shows how to check that a user owns a specific NFT, and how to send a transaction to a contract (in this example it is to award/transfer the NFT to the user ). The Moralis Web3Api contains a lot of operations for search NFTs, finding ownership, etc. so spend time learning this.
As to how to create land blocks and avatar - this is a detailed process. My suggestion is to search youtube for examples and tutorials for both Unity3D and Blender.
How to turn them into NFTs - again a very detailed process. You will either need to use OpenSea.io or another NFTs service to mint them manually or you will need to learn Solidity and write your own contracts. The second option enables you to set rules for ownership, transfer etc. For example, for the demo I wrote two contracts, the first is an ERC1155 contract for defining multiple NFTs. I then created a proxy contract to handle rules, minting and awarding. The Proxy is granted as minter role in the ERC1155 contract. Since minting happens via the Proxy, the Proxy contract owns the NFTs minted. Awarding is then a simple transfer making it very inexpensive in gas for the user to claim an award.
As long as it is EVM you could do some of it. The main thing you lose with a private chain is the use of Web3Api. If you use a private chain you will need to use Nethereum for all contract / chain interaction. The demo has some use of Nethereum you can look at but for most functionality of I refer you to their website which has good documentation.
hey, i wanna transfer tokens to another account from unity , should i create my own contract to make it work ?
also i was trying to get NFTs with my contract address using :
NftOwnerCollection nftsForContract = await MoralisInterface.GetClient().Web3Api.Account.GetNFTsForContract(addr.ToLower(), ContractAddress.ToLower(), ChainList.mumbai);
but the result list always contains one element even if I have more
Please send me the address and ContractAddress.
Have you tried this in the Moralis Admin panel?
Thanks,
David
Whatās the status of IPFS support?
Hi, are you having an issue with IPFS? The functionality to publish to IPFS is part of the Web3API (Storage endpoint). Please let me know what you are seeing.
Regards,
David
Not yet, Iām afraid!
Iām trying to test a solution which retrieves an encrypted wallet private key from IPFS. Iāll have to encrypt and upload it first, of course, but that wonāt happen in my client API.
@vivraan Okay let me know if I can help. For loading you just need the URL for the file and treat it as loading any other resource file from the web.
Regards,
David