Last active
August 29, 2015 14:27
-
-
Save linagee/f3e8d2f24f587d4dc785 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var weakHandsSource = 'contract weakHands { address owner; address triggerFriend; uint lockDate; function weakHands (address otherPerson) { owner = msg.sender; triggerFriend = otherPerson; lockDate = now + 5 days; } function requestEther(uint amount){ if (msg.sender==owner && now > lockDate) { owner.send(amount); } if (msg.sender==triggerFriend) { owner.send(amount); } } }'; | |
| var weakHandsCompiled = eth.compile.solidity(weakHandsSource); | |
| var triggerFriend = '0x03c4c03f163d51105bbc0e1a63077cb04210aa83'; | |
| var weakHandsContract = web3.eth.contract(weakHandsCompiled.weakHands.info.abiDefinition); | |
| var weakHands = weakHandsContract.new( | |
| triggerFriend, | |
| { | |
| from:eth.accounts[2], | |
| data:weakHandsCompiled.weakHands.code, | |
| value: web3.toWei(20, 'ether') | |
| gas: 1000000 | |
| }, function(e, contract){ | |
| if(!e) { | |
| if(!contract.address) { | |
| console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined..."); | |
| } else { | |
| console.log("Contract mined! Address: " + contract.address); | |
| console.log(contract); | |
| console.log("Your trigger friend is: " + triggerFriend); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment