Created
October 4, 2017 10:48
-
-
Save sonsongithub/0fd15b5edbae16f06c2817dd549dca94 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
| pragma solidity ^0.4.13; | |
| contract Onigiri { | |
| // contructのオーナー? | |
| address owner; | |
| // おにぎりの残数 | |
| uint public remains; | |
| // おにぎりの単価 | |
| uint constant price = 10; | |
| // 購入する顧客 | |
| mapping (address => uint) public customer; | |
| function Onigiri(){ | |
| owner = msg.sender; | |
| remains = 100; | |
| } | |
| // amount | |
| // おにぎりの注文個数 | |
| function buy(uint amount) payable { | |
| // 売買金額が指定の価格より低いと契約失敗 | |
| if (msg.value < price){ | |
| revert(); | |
| } | |
| customer[msg.sender] += amount; | |
| remains -= amount; | |
| if (remains == 0){ | |
| // 売り切れ | |
| selfdestruct(owner); | |
| } | |
| } | |
| // function () payable{ | |
| // buyAkushuken(1); | |
| // } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment