title: How to send ether from eoa to contract
body: <p>I need to send ether from externally owned account to contract. 
  All code I found so far looks like this</p>
  
  <pre><code>contract Contract {
     mapping (address =&gt; uint) balances;
  
     event Transfer(address indexed _from, uint256 _value);
  
     function deposit() public returns (uint) {
        balances[msg.sender] += msg.value;
        Transfer(msg.sender, msg.value);
        return balances[msg.sender];
     }
  }
  </code></pre>
  
  <p>But I can not understand how does it work. I thought it should look like this: we should run some send function which will take current contract address, sender address and amount.</p>
  
  <p>Can someone explain me the logic behind it? </p>
  
  <p>I also found the solution which correspond to this logic</p>
  
  <pre><code>contract Contract {
     function pay() payable {}
  }
  </code></pre>
  
  <p>and than call it from console like that</p>
  
  <pre><code>var contract
  Contract.deployed().then(function(instance) { contract = instance; })
  contract.pay.sendTransaction({from: eoa_address,to: contract_address,value: web3.toWei(amount,"ether"), gas:1000000})
  </code></pre>
  
  <p>But in this case <code>sendTransaction</code> function called outside of contact.
  Is there any way of calling it like from <code>this</code> perspective inside contract?</p>