oneclickdapp / oneclickdapp-v1

:zap::wrench::link: :shipit: Instantly build a dApp with a simple URL to bookmark or share with a friend.
http://OneClickdApp.com
MIT License
254 stars 69 forks source link

Bug: Out of Gas error on calling view function which uses msg.sender() #33

Closed pi0neerpat closed 6 years ago

pi0neerpat commented 6 years ago

Example: myEarnings() on http://oneclickdapp.com/camel-join/

Error message Unhandled promise rejection Error: "Returned values aren't valid, did it run Out of Gas?"

pi0neerpat commented 6 years ago

If you deploy the same contract on local ganache-cli, then there is no error!

pragma solidity ^0.5.0;

contract Sacrific3d {

    mapping(address => uint256) private playerVault;

    constructor()
        public
    {
        playerVault[0x1EEEe046f7722b0C7F04eCc457Dc5CF69f4fbA99]=100;
    }

    function myEarnings()
        external
        view
        returns(uint256)
    {
        return playerVault[msg.sender];
    }
}
pi0neerpat commented 6 years ago

Even weirder is it works on Ropsten, but not on Mainnet ropsten: http://oneclickdapp.com/vampire-common/ mainnet: http://oneclickdapp.com/bison-career/

pi0neerpat commented 6 years ago

This seems to be an issue with the ABI not having a name for the output for a view function. I fixed this by setting outputs[0].name to "earnings" in the the ABI, and creating a new dApp with this ABI.

All, please add a name to your outputs in your ABI, until a fix is implemented to add it automatically upon creation

    {
        "constant": true,
        "inputs": [],
        "name": "myEarnings",
        "outputs": [
            {
                "name": "earnings",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "constructor"
    }
pi0neerpat commented 6 years ago

This has been fixed in commit 5061a41 Now, all unnamed outputs in all view functions are automatically given a name.