[Solved]Unity WebGL NFT Minting issue

Hello,
With Unity WebGL template, sending smart contract giving error as below. when confirming at wallet

“Uncaught (in promise) Error: invalid BigNumber string (argument=“value”, value=“08da699fe0c1f2b0”, code=INVALID_ARGUMENT, version=bignumber/5.1.1)”


I found that this is happening here.

ExecuteContractFunction function in unity sdk

Solved.
Issue was in contract ERC115. unity was passing wrong bigint and blank byte array.
changed value to only bigint and instead of “” now sending [] in byte array.

Issue is in WebGL only. Not on other platform

i have same problem…pls more explain…i dont undrestand

Actually as per demo contract, in byte data field is issue.
when we pass data directly from editor or desktop then it does not give any error but when we send it through webgl, then data is converted from json to string , and in that it is passing null “” value to server and that is causing error with webgl.

now solution is in purchase script >> PurchaseItemFromContract (function)
replace this line " byte[] data = Array.Empty(); " with this “string[] data = new string[0];

and create if else condition so that this replacement works only in webgl.

Hope this helps

I am also having this issue and not sure what to change, datetime.now.ticks returns an error in web browsers, here is my current code;

{
public async UniTask ExecuteMinting(string metadataUrl)

        long currentTime = DateTime.Now.Ticks;

        Debug.Log(currentTime);
        // Dummy TokenId based on current time
        _currentTokenId = new BigInteger(currentTime);

        object[] parameters = {
        _currentTokenId.ToString("x"), // This is the format the contract expects
        metadataUrl
    };

        // Set gas estimate
        HexBigInteger value = new HexBigInteger(0);
        HexBigInteger gas = new HexBigInteger(0);
        HexBigInteger gasPrice = new HexBigInteger(0);

        string resp = await Moralis.ExecuteContractFunction(ContractAddress, ContractAbi, "mintItem", parameters, value, gas, gasPrice);

        return resp;
    }

What version of the Moralis Unity SDK and Unity are you using? Did you update anything compared to when DateTime.Now.Ticks last worked?

Unity version 2021.3.3f1, Moralis SDK 1.2.0,

I cant think of anything that I’ve updated but it only dosnt work on a webGL build, other platforms seem fine

As stated by the original poster I recieve the “Error: invalid BigNumber string” error

Have you tried the latest 1.2.5 of the SDK?

Just tried it now after reading your post, same error unfortunately in 1.2.5 and 1.2.6;

Uncaught (in promise) Error: invalid BigNumber string (argument=“value”, value=“08da7a60e70881d0”, code=INVALID_ARGUMENT, version=bignumber/5.1.1)

value=“08da7a60e70881d0”

Where is this value coming from (in your code)? It doesn’t seem to be a valid BigNumber.

value should be coming from the gas estimate part;

        // Set gas estimate
        HexBigInteger value = new HexBigInteger(0);
        HexBigInteger gas = new HexBigInteger(0);
        HexBigInteger gasPrice = new HexBigInteger(0);

having no problems in editor or windows builds with the up to date sdk also

Since it doesn’t work on WebGL only with the same code, can you please make an issue.

okay no problem I’ve added an issue, Im currently trying to find something to replace datetime.ticks.now with but not having any luck so far

just for future referance, this is the full error code, nothing to do with date.time, that was my typing error,

The error is below;

“Uncaught (in promise) Error: invalid BigNumber string (argument=“value”, value=“08da7ca0fbd02400”, code=INVALID_ARGUMENT, version=bignumber/5.1.1)”

Im currently trying to find something to replace “HexBigInteger value = new HexBigInteger(“0x0”);” but no luck so far, I think the OP’s solution is on the right track but I’m not sure how to implement it