1

I'm using MetaMask to connect to Rinkeby and I'm deploying the contracts via Remix. When I call the function returnsenderbalance it returns

115792089237316195423570985008687907853269984665640564039456084007913129639935

rather than my balance in Wei. The code is below:

pragma solidity ^0.4.11;

contract returnbalance{
    function returnsenderbalance() constant returns (uint){
        return msg.sender.balance;  
    }
}
  • 1
    Can confirm behaviour with contract deployed here Could not find a solidity version where it does not happen, though works as expected in the Javascript VM. currently looking through bytecode – o0ragman0o May 29 '17 at 2:01
  • 1
    function eventSenderBalance() {SenderBalance(msg.sender, msg.sender.balance); } logs the correct balance. – o0ragman0o May 29 '17 at 2:14
  • Does anyone want to chime in and describe how this was ultimately resolved? I'm thinking compiler and curious about the details. – Rob Hitchens - B9lab Oct 12 '18 at 4:18
0

This is related to:

eth/api_backend.go

func (b *EthAPIBackend) GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error) {
===> state.SetBalance(msg.From(), math.MaxBig256)
vmError := func() error { return nil }
context := core.NewEVMContext(msg, header, b.eth.BlockChain(), nil)
return vm.NewEVM(context, state, b.eth.chainConfig, vmCfg), vmError, nil
}

math.MaxBig256 == 115792089237316195423570985008687907853269984665640564039455084007913129639935

Is a constant in Geth( common/math/big.go)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.