The deployed contract has a function as below:

function checkBalance() onlyTrainee constant returns (uint256) {
    return traineeBalances[msg.sender];

When I call checkBalance(), it always checks the balance of sender 0x00..00. There is no input field that lets me fill out who I am. In web3, I would accomplish that with checkBalance().call({from: '0x123....'}).

Is there any way to indicate to MyEtherWallet who the caller (msg.sender) should be?

Note that this is not about setting the sender of a transaction, which of course only works if I have the private key.

  • I'm also interested in MyCrypto. – carver Aug 14 '18 at 21:20
  • I dont' understand the question. You need to know every address, which called successfully the function checkBalance()? You could store every address which initiated the function in a log or in a struct, would this be a solution for you? – sunwarri0r Aug 15 '18 at 6:22
  • Are you (lambeta) the same as @carver? – WBT Aug 15 '18 at 17:15
  • If familiar with using web3, why not just use that to call the function? If this question is about the user interface of a specific wallet software package, is it MyEtherWallet or MyCrypto? – WBT Aug 15 '18 at 17:21
  • This was originally about MyEtherWallet. (The question was asked before the fork, so it's hard to say which the asker would want now). I'll remove MyCrypto again since they are probably close enough that it's unnecessary to come to consensus. – carver Aug 15 '18 at 21:21

There does not seem to be any way to set the msg.sender of a read operation in MyEtherWallet. This would be a useful feature, so maybe consider opening an issue at the github.

There is nothing fundamentally stopping you from simulating a transaction from an account you don't own, you can do this in your preferred flavor of web3 by simply setting the from field in the .call to the address you want.


You can only "be" one of the accounts you have access to. You can't spoof to be an arbitrary account - that'd be a huge security hole.

The function you included does not allow for input and therefore there's no input possibility. The msg.sender is always the one who sends the transaction, so it will be whoever calls the function. It can also be a contract address if a contract calls another contract.

Something like from is not a Solidity/Ethereum concept but it's a concept of wrapper libraries such as web3. It's typically not given as an option for end users - if they have access to multiple accounts they can just unlock/open/whatever the account they wish to use and call the contract from that. It can never provide functionality which wouldn't be native to Ethereum - it will only allow you to specify from to be one of accounts you have access to.

  • Thanks, I updated the question to clarify that it was about a call, not a transaction (which I'm fairly sure was the original intent). – carver Aug 15 '18 at 17:02

If your goal is just to get the balance of the specific address then we can do on other way without calling checkBalance() function as following step

  1. Read storage from smart contract address: GetStorageAt('')
  2. pass sender as input param to calculate the storage position of it's traineeBalances on the smart contract storage from (1)

For more details, you can refer to this link: https://medium.com/aigang-network/how-to-read-ethereum-contract-storage-44252c8af925

Hope this help!


When interacting with the contract, what account are you using to send/call the transaction? That is, what account is/would be paying the gas to execute the function?

In MyEtherWallet, for example, it shoud be over on the right, under Account Address (here, for example, it's 0xaFFb8483F0...):

Whatever shows for you when you're calling checkBalance, that is the account which should be the answer to your question.

  • Thanks, I updated the question to clarify that it was about a call, not a transaction (which I'm fairly sure was the original intent). – carver Aug 15 '18 at 17:02
  • @carver That edit changed the question fairly substantially. – WBT Aug 15 '18 at 17:21
  • 1
    I'm having a hard time seeing how the intent could have been to send a transaction. The original wording: "After interacted with the contract on MyEtherWallet, I call checkBalance() but there is no input [field] ... that let me ... fill ... who I am". The clues: a) the asker knows how to issue a transaction from an account, which was already done during the setup b) asker used the word call c) it is a constant function, there's no point in issuing a transaction – carver Aug 15 '18 at 21:19

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.