3

I'd like to move ether from one arbitrary account to another account following a contract. From the execution method, I'd like to send ether. Can I do that?

contract MultiplyContract{
    address public sender;
    address public receiver;
    uint public price;
    function MultiplyContract(
      address _sender,
      address _receiver,
      uint _price
      ){
      sender = _sender;
      receiver = _receiver;
      price = _price;
    }
    function Execution(){
      //sender send ether to receiver//
    }
    function () {
      throw;
    }
}
eth
  • 85,679
  • 53
  • 285
  • 406
Toshi
  • 2,357
  • 8
  • 23
  • 34
  • I think the question still needs to be clarified, maybe use "arbitrary account to another one"... Otherwise the answer is going to be the same as http://ethereum.stackexchange.com/questions/3649/how-to-transfer-ether-between-accounts-in-solidity – eth May 06 '16 at 14:13
  • This sounds like an XY problem. What are you actually trying to do? – Nick Johnson May 06 '16 at 22:30
  • @NickJohnson I'd like to make swap trading account. According to the contract info, I'll want let it move ether from one account to another. – Toshi May 07 '16 at 01:23
  • @toshikaseda The way to do that is to hold ether in the contract, and keep a map recording individual account balances. – Nick Johnson May 07 '16 at 17:44

1 Answers1

5

No. A contract can only spend Ether from its own funds. Being able to sign a transaction for an arbitrary account would entail the contract having access to said account's private key, making it public for everyone.

Péter Szilágyi
  • 10,436
  • 39
  • 42
  • Thank you Péter. Btw, I'd like to realise derivative, that move ether of one eoa to another one according to a contract. Can I actualise it? – Toshi May 07 '16 at 01:27