Skip to content

Instantly share code, notes, and snippets.

@sonsongithub
Created October 4, 2017 10:48
Show Gist options
  • Select an option

  • Save sonsongithub/0fd15b5edbae16f06c2817dd549dca94 to your computer and use it in GitHub Desktop.

Select an option

Save sonsongithub/0fd15b5edbae16f06c2817dd549dca94 to your computer and use it in GitHub Desktop.
コントラクトのコード
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