can I use a Externally Owned Account to call contract account function to transfer ether to other Externally Owned Accounts, and the ether is from contract account.


Yes you can and it's very simple to do.

Something like this:

pragma solidity ^0.5.1;

contract MyContr {
    function transfer(address payable receiver, uint amount) public {
        require(address(this).balance >= amount);

Then you deploy the contract, get its ABI and address, input those into a wallet software of your choice and send a transaction to the transfer function of the contract with the required parameters.

You should of course add all sort of security checks (not everyone should be allowed to do the transfer).

  • Am I right to think so: If one EOA(1) call smart contract transfer function to another EOA(2), it means that it will cost smart contract account's ether instead of EOA(1). – Lance li Apr 11 '19 at 6:40
  • The Ether can come from either EOA1 or from the smart contract - it's up to you to decide how it should work – Lauri Peltonen Apr 11 '19 at 6:43
  • yeah, but I don't know how to let the ether come from smart contract, I tried in remix, but I found I take the ether from the EOA1. – Lance li Apr 11 '19 at 6:59
  • Just use the code I gave you. Of course the contract has to have some Ether to be able to send it. – Lauri Peltonen Apr 11 '19 at 9:24
  • @LauriPeltonen The require seems redundant here. – user19510 Apr 11 '19 at 11:26

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.