unity-web3-game-kit icon indicating copy to clipboard operation
unity-web3-game-kit copied to clipboard

Unity webGL - Execute Contract Function - Minting Issue (HexBigInteger - Invalid Big Number Returned (Error: invalid BigNumber string))

Open tseabz opened this issue 2 years ago • 5 comments

tseabz avatar Aug 10 '22 09:08 tseabz

Please post sample code - looks like a valid error.

xactant avatar Aug 25 '22 14:08 xactant

Here is my current code, the issue that im having is that it works in editor & on desktop platform but when i build to webGL I recieve the error;

{ 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;
}

tseabz avatar Aug 25 '22 16:08 tseabz

Okay I think we fixed an issue for this related with Nethereum which is where this is happening - are you using the latest version of the Unity Game Kit?

We also submitted an issue to the Nethereum team.

xactant avatar Aug 26 '22 12:08 xactant

okay and yes im using version 1.2.6

tseabz avatar Aug 26 '22 13:08 tseabz

interestingly by removing some code and using a different smart contract (from elden ring tutorial) it works, although a few mintues delay when compared to desktop build;

    public async UniTask<string> ExecuteMinting(string metadataUrl)
    {

        object[] parameters = {
            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, "getItem", parameters, value, gas, gasPrice);

        return resp;
    }

tseabz avatar Aug 26 '22 15:08 tseabz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 25 '22 20:10 stale[bot]