Created
January 30, 2018 14:57
-
-
Save anonymous/5885b759819977cc61baf0ebc87b79b1 to your computer and use it in GitHub Desktop.
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=false&gist=
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
| pragma solidity ^0.4.0; | |
| contract EtherTransferTo { | |
| function () public payable { | |
| } | |
| function getBalance() public returns (uint) { | |
| return address(this).balance; | |
| } | |
| } | |
| contract EtherTransferFrom { | |
| EtherTransferTo private _instance; | |
| function EtherTransferFrom() public { | |
| // _instance = EtherTransferTo(address(this)); | |
| _instance = new EtherTransferTo(); | |
| } | |
| function getBalance() public returns (uint) { | |
| return address(this).balance; | |
| } | |
| function getBalanceOfInstance() public returns (uint) { | |
| //return address(_instance).balance; | |
| return _instance.getBalance(); | |
| } | |
| function () public payable { | |
| //msg.sender.send(msg.value); | |
| address(_instance).send(msg.value); | |
| } | |
| } |
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
| pragma solidity ^0.4.0; | |
| contract FuncConcert { | |
| address owner; | |
| uint public tickets; | |
| uint public constant price =1 ether; | |
| //diffrent modifier represent value | |
| // | |
| mapping (address => uint) public purchasers; | |
| function FuncConcert(){ | |
| owner = msg.sender; | |
| tickets =5; | |
| } | |
| function () payable{//fallback function | |
| buyTickets(1); | |
| } | |
| function buyTickets(uint amount) payable { | |
| //msg.value how much ether send this function | |
| if (msg.value != (amount*price) || amount > tickets){ | |
| throw; | |
| } | |
| purchasers[msg.sender] += amount; | |
| tickets -= amount; | |
| if (tickets==0){ | |
| selfdestruct(owner); | |
| } | |
| } | |
| /* | |
| function Balance() public returns(uint){ | |
| return this.balance(); | |
| } | |
| */ | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment