Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetaMask returning bad value for solidity account.balance #2999

Closed
danfinlay opened this issue Jan 16, 2018 · 3 comments
Closed

MetaMask returning bad value for solidity account.balance #2999

danfinlay opened this issue Jan 16, 2018 · 3 comments
Labels
area-background Issues relating to the extension background process. type-bug Something isn't working

Comments

@danfinlay
Copy link
Contributor

Reported by a user, referred to us by the Solidity team here:
ethereum/solidity#2325

Seems we're returning a strange result for account.balance, like msg.sender.balance.

@2-am-zzz 2-am-zzz added type-bug Something isn't working P3-soon area-background Issues relating to the extension background process. labels Jan 17, 2018
@madmartian5
Copy link

Any update on this?

@danfinlay
Copy link
Contributor Author

No, sorry, this hasn't received any attention at all.

I’ve taken the steps to reproduce, here is what I did, and what I found:

Solidity

pragma solidity ^0.4.11;

contract Test {
function balanceOfEther(address user) public constant returns (uint256) { return user.balance; } 
}

Deployed to Ropsten at 0x64488483c613753cb33ef160cbb3ed8c7e866c08

For account 0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb

When balance is fetched like this:

curl 'https://api.infura.io/v1/jsonrpc/ropsten/eth_getBalance?params=%5B%220xc5b8dbac4c1d3f152cdeb400e2313f309c410acb%22%2C%22latest%22%5D' -H 'pragma: no-cache' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en,fr;q=0.9,en-US;q=0.8,es;q=0.7' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36' -H 'accept: */*' -H 'cache-control: no-cache' -H 'authority: api.infura.io' --compressed

it returns:

{“jsonrpc":"2.0","id":1,"result":"0x3a5511a089c2f180”}

We call to infura:

curl 'https://api.infura.io/v1/jsonrpc/ropsten' -H 'pragma: no-cache' -H 'origin: null' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en,fr;q=0.9,en-US;q=0.8,es;q=0.7' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36' -H 'content-type: application/json' -H 'accept: application/json' -H 'cache-control: no-cache' -H 'authority: api.infura.io' --data-binary '{"id":570283474,"jsonrpc":"2.0","method":"eth_call","params":[{"from":"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb","to":"0x64488483c613753cb33ef160cbb3ed8c7e866c08","value":"0x0","data":"0x21114904000000000000000000000000c5b8dbac4c1d3f152cdeb400e2313f309c410acb","gas":"0x2dc6c0"},"latest"]}' --compressed

It returned:

{"jsonrpc":"2.0","id":570283474,"result":"0xfffffffffffffffffffffffffffffffffffffffffffffffffdeb17cb73b0ffff"}

Interpreted by remix as:

0: uint256: 115792089237316195423570985008687907853269984665640564039457434007913129639935

Which is indeed the base 10 representation of the Infura result.

One user in the remix issue reported:

about 50% of the time I get the correct result, other times I get 115792089237316195423570985008687907853269984665640564039455084007913129639935. Perhaps a geth/MetaMask issue - never seen with JavascriptVM.



This is the same number we got for this result. I tried many more times, and never was able to get a correct result from Infura here. Reaching out to Infura to see what they think, I wonder if this is a Geth bug.

@Gudahtt
Copy link
Member

Gudahtt commented Nov 27, 2020

This appears to have been fixed in ethereum/go-ethereum#16999

I haven't confirmed this has been fixed, but I'll close it for now anyway since it doesn't seem to be a problem with MetaMask itself.

@Gudahtt Gudahtt closed this as completed Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-background Issues relating to the extension background process. type-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants