Cannot access balance by using the json rpc call in Unity

Hi everyone, I’m trying to integrate MetaMask SDK in my Unity project, it’s university project. I want to show the user current user his balance in ETH but the json rpc call fails and I don’t know why. I can’t find anything useful in the docs.

    {
        var wallet = MetaMaskUnity.Instance.Wallet;
        var transactionParams = new MetaMaskTransaction
        {
            To = "0xbF09120dada33C13765671158bC0364ce4604b7C",
            From = MetaMaskUnity.Instance.Wallet.SelectedAddress,
            Value = "0x"
        };
        var request = new MetaMaskEthereumRequest
        {
            Method = "eth_getBalance",
            Parameters = new MetaMaskTransaction[] { transactionParams }
        };
        var balance = await wallet.Request(request);
        Debug.Log("Balance found: " + balance);
    }

Hi it’s awesome to see you are trying MetaMask SDK! Could you share the failed rpc do you have an error output. Are you using any node provider? Any chance you could share steps to reproduce it. Thanks

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.