My account address on Remix IDE is 0xCA3…a733c and wallet address is 0x147…C160C. Following is my code obtained from Solidity Tutorial. In this code, buyer address is passed as an argument. I have got 3 addresses in the image, which one is the buyer address? Also in the log file I have “to” and “from” addresses, please tell me which one is the buyer address?

pragma solidity 0.5.4;
contract MyContractEtherEvents {
    mapping(address => uint256) public balances;
    address payable wallet;
    event Purchase(
        address indexed _buyer,
        uint256 _amount

    constructor(address payable _wallet) public {
        wallet = _wallet;

    function() external payable {

    function buyToken() public payable {
        balances[msg.sender] += 1;
        emit Purchase(msg.sender, 1);

The log file is given below:

transaction hash 0xa4484b15bd6e83c5377bbc4e21f69e8c208a02c3ea0187ffa77cb29c9352df6e from 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c to MyContractEtherEvents.balances(address) 0x692a70D2e424a56D2C6C27aA97D1a86395877b3A transaction cost 23832 gas (Cost only applies when called by a contract) execution cost 1152 gas (Cost only applies when called by a contract) hash 0xa4484b15bd6e83c5377bbc4e21f69e8c208a02c3ea0187ffa77cb29c9352df6e input 0x27e...a733c decoded input { "address ": "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c" } decoded output { "0": "uint256: 4

The image of the project is:

Problem with understanding 3 addresses

Somebody please guide me.


1 Answer 1


0x147 ... is going to the constructor and ultimately to wallet in the code.

0xCA3 ... is msg.sender

0x692 ... is the contract. Remix looks after that for you, but raw transactions would be to the contract, from: 0xCA3 ... and about 0x147 ... which is being passed as msg.data and unpacked by functions like buy() ... { which uses it.

Hope it helps.


I realize it's a contrived example from a tutorial and maybe isn't finished yet. But just to clarify the comments. This might make more sense:

    balances[msg.sender] += msg.value; // 1:1 trade
    emit Purchase(msg.sender, msg.value); // that's what happened. 
  • This means 0xCA3 ... is the buyer because it is sending Ether. I can't understand what is the purpose of '1' in "emit Purchase(msg.sender, 1)", please guide me.
    – zak100
    Jan 21, 2020 at 23:17
  • 1
    It looks like a token contract that is merely accounting, so the buyer "gets" one token with ` balances[msg.sender] += 1`. Then the contract forwards eth received to the wallet, which must be the guy who deployed the contract. He wants the money. It's not particular about how money was sent. Anything will do, but that is probably later in the tutorial. Jan 22, 2020 at 0:52
  • 1
    I guess 1 is implied by += 1. It would make more sense to do something like += msg.value. That way it would trade money in for tokens at a ratio of 1:1. Jan 22, 2020 at 0:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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