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,370 points
1,596 views

1 answer to this question.

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
• 26,740 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
• 17,100 points
3,626 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
• 17,100 points
734 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
• 17,100 points
2,701 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
1,947 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,472 views
+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,610 points
1,468 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
• 26,740 points
3,261 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
• 26,740 points
767 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP