safesend example

From Sloppy Motmot, 7 Years ago, written in Plain Text, viewed 308 times.
URL https://paste.steamr.com/view/92e3fe71 Embed
Download Paste or View Raw
  1. pragma solidity ^0.4.0;
  2.  
  3. contract SimpleBank {
  4.     address public owner;
  5.    
  6.     // even that gets logged on block chain...
  7.     event MyWorthIs(uint balance);
  8.    
  9.     /*
  10.      */
  11.     function SimpleBank() {
  12.         // the 'owner' is the person who creates this contract
  13.         owner = msg.sender;
  14.     }
  15.    
  16.     /*
  17.      */
  18.     function() payable {
  19.        
  20.     }
  21.    
  22.     /*
  23.      */
  24.     function Worth() {
  25.         MyWorthIs(this.balance);
  26.     }
  27.    
  28.     function send(address _to, uint256 _amount) {
  29.         _to.send(_amount);
  30.     }
  31.    
  32.     /*
  33.      * Suicide function will kill the contract.
  34.      */
  35.     function kill() {
  36.         suicide(msg.sender);
  37.     }
  38.    
  39. }
  40.  
  41.  
  42. contract IsAlive {
  43.     address public thing;
  44.    
  45.     function IsAlive(address _thing) {
  46.         thing = _thing;
  47.     }
  48.    
  49.     function() payable {
  50.         if (SimpleBank(thing).owner() == 0) {
  51.             // the contract is dead, send amount back
  52.             msg.sender.send(msg.value);
  53.         } else {
  54.             // don't need gas?
  55.             thing.call.gas(300000000).value(msg.value)();
  56.             // you can call a specific funtion by..
  57.             // thing.call.gas(x).value(y)(bytes4(sha3("pay()")));
  58.         }
  59.     }
  60.    
  61.     /*
  62.      * Suicide function will kill the contract.
  63.      */
  64.     function kill() {
  65.         suicide(msg.sender);
  66.     }
  67.    
  68.    
  69. }
  70.  

Reply to "safesend example"

Here you can reply to the paste above