How do I send ether from an EOA to a smart contract?

0 votes

I am trying to write a simple smart contract that will share any ether it gets between two EOAs. I am unable to find the command I need to run from the geth console to send the ether "to the share function". What is the syntax for this command? 

pragma solidity ^0.4.0;
contract sharer {
    address owner;
    address A;
    address B;

    function sharer (address _A, address _B) public {
        A = _A;
        B = _B;
    }

    function share () payable public {
        A.transfer(msg.value/2);
        B.transfer(msg.value/2);
    }
}
Sep 27, 2018 in Blockchain by slayer
• 29,040 points
36 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You include ether to send in the transactionObject for the method call.

const txObject = {
  value: web3.toWei(amtInEther, 'ether')
};

shareContractInstance.share.sendTransaction(txObject);

The other options for the transaction object can be found here.

answered Sep 27, 2018 by digger
• 27,620 points

Related Questions In Blockchain

0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 16,450 points
217 views
0 votes
1 answer

How is a request sent from an app to a smart contract?

Yes, the contract is distributed by every node ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 16,450 points
33 views
0 votes
1 answer

How do I withdraw the balance from a contract on Ethereum test blockchain?

Your need to improvise your code a ...READ MORE

answered Aug 3, 2018 in Blockchain by Perry
• 16,450 points
44 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
88 views
0 votes
1 answer
+3 votes
2 answers

How to run ethereumjs using Node.JS

You need to install testrpc globally on ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,620 points
109 views
0 votes
1 answer

How do display all the events logs from a smart contract?

You'll need to watch the events. const filter ...READ MORE

answered Oct 3, 2018 in Blockchain by digger
• 27,620 points
49 views
0 votes
1 answer

How can I take the required info and send it to a div in the html page?

window.onload=function(){ var anima = document.getElementById("crypto"); var ret = document.getElementById("btn"); ret.addEventListener("click",function(){ var ...READ MORE

answered Sep 6, 2018 in Blockchain by digger
• 27,620 points
27 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.