Skip to content

Instantly share code, notes, and snippets.

@blueplanet
Created December 11, 2017 06:30
Show Gist options
  • Save blueplanet/7b7d230a2de2b742b2075a11b7efe39f to your computer and use it in GitHub Desktop.
Save blueplanet/7b7d230a2de2b742b2075a11b7efe39f to your computer and use it in GitHub Desktop.
Solidity 言語仕様 コントラクト篇 ref: https://qiita.com/blueplanet/items/08a86785f8dcdc6cffe9
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;
}
}
contract Register{
modifier costs(uint price) {
if (msg.value >= price) {
_;
}
}
function register() costs(price) {
// 実際の処理
}
}
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