Ethereum Unity3D Boilerplate Questions

Thx! I will share as soon as possible! Nice job in this Boilerplate! Thanks for it

1 Like

@dgoodrich any updates on this?

1 Like

Sorry - I am not sure which “this” you are referring to.
If the WebGL / Metamask interface, I am working on it.

If transferring ERC20 questions I am going to go ahead and create an example.

@dgoodrich this is what I was referring to.


You should be able to see a rightward pointing arrow and the profile picture of the person whose message is being replied to. Clicking on it opens up the contextual message. You can further click on the upward arrow to go to that message.

1 Like

From what I saw this looks like a response you made to another user. A question about transferring tokens. Is this correct?

Not at all. I was attempting to continue my thread of issues.

Okay, please let me know what the issue is. The volume I receive is very high.

Well the problem with using the same server for cloud functions on different apps persists (returning an error related to the session token), even though you mentioned you’re not able to reproduce it on your end.

Reminder!

The best thing would be to try and replicate your code and see what I might be getting wrong.

1 Like

How can I get a balance for the specific token? I can get the balance but can’t transfer it from wei.

// const balances = await Moralis.Web3API.account.getTokenBalances(options);
string tokenBalance = MoralisInterface.GetClient().Web3Api.Account.GetNativeBalance("contract adress here", 'chain id here').Balance;

Can’t find this function (FromWei) below.

//Convert token value to ETH style with 18 decimals
//If you do not specify decimals, 18 decimals will be automatically used
const tokenValue = Moralis.Units.FromWei("2000000000000000000")
1 Like
 error CS0029: Cannot implicitly convert type 'Cysharp.Threading.Tasks.UniTask<System.Collections.Generic.List<Moralis.WebGL.Web3Api.Models.Erc20TokenBalance>>' to 'System.Collections.Generic.List<Moralis.WebGL.Web3Api.Models.Erc20TokenBalance>'

Solution?

1 Like
List<Erc20TokenBalance> tokensBalance = MoralisInterface.GetClient().Web3Api.Account.GetTokenBalances(addr.ToLower(), (ChainList)ChainId);
            Erc20TokenBalance ourToken = new Erc20TokenBalance();
            //filter our Token by name
            for (int i = 0; i < tokensBalance.Count; i++)
            {
                Debug.Log(tokensBalance[i].Name + " " + tokensBalance[i].Balance);
                if (tokensBalance[i].Name == tokenName)
                {
                    Debug.Log("It's my Token!!!");
                    ourToken = tokensBalance[i];
                    //break;
                }

I use this and work as well

1 Like

The issue with this function is, it freezes Unity when calling every second because I need to check player balance every second.

This is the freezing part:
MoralisInterface.GetClient().Web3Api.Account.GetTokenBalances(addr.ToLower(), (ChainList)ChainId);

How can we make this function execute in more frames so that it will not freeze unity?

1 Like

Make sure you are using the 1.0.4 release. The update for this was posted in the code a couple weeks ago but included in the latest release. All of the Web3Api endpoints are now async :slight_smile:

Are you using WebGL on non-WebGL? If you are not using WebGL make sure your “using” references do not have WebGL in them.

Just a note, the Web3API calls are now all async. Release 1.0.4 has this code. You can also download the code in the repo.

In version 1.0.4, can we now login to the wallet without a QR code?

1 Like

No, I using the 1.0.4 and I cant

1 Like

Only in iOS and Android.

For desktop you will always use QR Code.

For WebGL you still need the QR Code. However I am working on an update to replace Wallet Connect in WebGL with a direct interface to Metamask so that WebGL with interact with Metamask as browser apps do.

1 Like

Amazing! My team needs WebGL - Wallet connection for further development. We can’t wait for this great update! :slight_smile:

1 Like

WebGL currently does have a wallet connection - just the Wallet connect QR code one. The Metamask Interface should be ready by the end of the month.

1 Like