pragma solidity ^0.4.16; contract Address { function Address() public { } // fallback関数(匿名・引数・戻り値を持たない) function () payable public {} // アドレス(アカウント)が保持するetherを返す function getBalance(address _thisAddress) view public returns (uint) { // address(0) はデプロイされるようとしているコントラクトのアドレス if (_thisAddress == address(0)) { _thisAddress = this; } return _thisAddress.balance; } // 相手アドレスにetherを送金 function transfer(address _to, uint _amount) public { _to.transfer(_amount); } // 相手アドレスにetherを送信(失敗時は処理を全てrevertする) function send(address _to, uint _amount) public { if (!_to.send(_amount)) { revert(); } } // 相手アドレスにetherをgasを指定し送信(失敗時は処理を全てrevertする) function call(address _to, uint _amount) public { if(!_to.call.value(_amount).gas(100000)()){ revert(); } } // コントラクトからお金を引き出す function withDraw() public { address to = msg.sender; to.transfer(address(this).balance); } //ガスを設定してコントラクトからお金を引き出す function withDraw2() public { address to = msg.sender; if(!to.call.value(address(this).balance).gas(100000)()){ revert(); // throw; } } }
0.4.21