Guest User

Untitled

a guest
Jul 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. web3.eth.getBalance('0x123').then(console.log) // 0
  2.  
  3. address public recipient; // The account receiving the payments.
  4.  
  5. function receive(uint256 amount) public {
  6. require(msg.sender == recipient);
  7.  
  8. recipient.transfer(amount);
  9.  
  10. }
  11.  
  12. constructor(address _recipient)
  13. public
  14. payable
  15. {
  16. recipient = _recipient;
  17. }
  18.  
  19. var contractInstance = new web3.eth.Contract(abi, '0x456' /*0x456 is contract address*/);
  20.  
  21. contractInstance.methods.close(10 /*0x123 wants to receive 10 wei*/).send({ from: '0x123' }, function(error, result) {
  22.  
  23. console.log(error);
  24.  
  25. console.log(result)
  26.  
  27. });
Add Comment
Please, Sign In to add comment