Created
December 11, 2017 06:30
-
-
Save blueplanet/7b7d230a2de2b742b2075a11b7efe39f to your computer and use it in GitHub Desktop.
Solidity 言語仕様 コントラクト篇 ref: https://qiita.com/blueplanet/items/08a86785f8dcdc6cffe9
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 SingleNumRegister { | |
uint storedData; | |
address owner; | |
function SingleNumRegister() { | |
// デプロイするアカウントのアドレスをオーナーとして保持する | |
owner = msg.sender; | |
} | |
modifier onlyOwner { | |
// 呼び出す元のアドレスがオーナー以外の場合、revert()処理走って状態変更を巻き戻して実行を止める | |
require(msg.sender == owner) | |
// _ は、関数修飾子が付けられている関数本体を実行する意味 | |
_; | |
} | |
function set(uint x) onlyOwner { | |
storedData = x; | |
} | |
function get() constant returns (uint retVal) { | |
return storedData; | |
} | |
} |
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
contract Register{ | |
modifier costs(uint price) { | |
if (msg.value >= price) { | |
_; | |
} | |
} | |
function register() costs(price) { | |
// 実際の処理 | |
} | |
} |
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 C { | |
uint constant x = 32**22 + 8; | |
string constant text = "abc"; | |
function f(uint a, uint b) constant returns (uint) { | |
return a * (b + 42); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment