0

I want to execute the send function that sends ether from the sender to the receiver, the code is as shown below.

    contract Sender {   
    function send(address _receiver , uint amount) public payable {
        address payable pReceiver = address(uint160(_receiver)); 
         pReceiver.send(amount); 
    } 
    function sending(address _receiver , uint amount) public payable {   
        address payable pReceiver = address(uint160(_receiver));     
        pReceiver.send(amount);
     }
 }

  contract Receiver {
  uint public a = 2;
  function aIs() public returns (uint256){
          return a;
      }

  function () payable external {
    if (msg.value == 0){
              require(true,"value is 0");
              a = 0;
          }   
          else{
             require(true,"value is not 0");
              a = 1;
          }
          aIs();
  }
}

///////////////////////////////////////////////////

I just do like this in geth console.

------------------------------------------------
> loadScript('/home/ether/go-ethereum/build/bin/node2/rece.js')

true
> var receBin = '0x'+receBin
undefined
> var receAbi = receAbi
undefined
> var sendBin = '0x'+sendBin
undefined
> var sendAbi = sendAbi
undefined
> var conR = eth.contract(receAbi)
undefined
> var conS = eth.contract(sendAbi)
undefined
> personal.unlockAccount(eth.accounts[0]) 
Unlock account 0x25bd266f595501e1a0c2319f36b14ff942fa6901
Passphrase: 
true
> var conSend = conS.new({from:eth.accounts[0], data:sendBin, gas:'5000000'})
----------------------------------

And when I try to execute Sender's function send, with Recevier's address

-----------------------------------
conSend.send.call(conReceive.address, 1)
evm.go/call function
>>input : d0679d34000000000000000000000000a40c342aaf0f4e8550395467627295327a60678d0000000000000000000000000000000000000000000000000000000000000001
>>using getDataBig : d0679d34
[1][op: PUSH1]
[2][op: PUSH1]
[3][op: MSTORE]
[4][op: PUSH1]
[5][op: CALLDATASIZE]
[6][op: LT]
[7][op: PUSH2]
[8][op: JUMPI]
[9][op: PUSH1]
[10][op: CALLDATALOAD]
[11][op: PUSH1]
[12][op: SHR]
[]

it is stop before running send

Could you give me some help??

  • var sendBin = '0x'+sendBin can you verify value of sendBin is correct? – Niklas Feurstein Dec 10 '19 at 15:26
  • and does conReceive.address contain a value at all? – Niklas Feurstein Dec 10 '19 at 15:28
  • Don't I have to put an x in front of it? What does "conReceive.address contain a value" mean? – atti Dec 10 '19 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.