Skip to content

Instantly share code, notes, and snippets.

@code-machina
Last active December 17, 2018 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code-machina/1748c86a31ebe92162191462b0ff3f08 to your computer and use it in GitHub Desktop.
Save code-machina/1748c86a31ebe92162191462b0ff3f08 to your computer and use it in GitHub Desktop.
Examples of solidity ^0.5.1
pragma solidity ^0.5.1; // (1) Version pragma
contract Helloworld {
// 문자열 멤버 변수
string public greeting;
// memory 키워드가 반드시 있어야 한다.
// greeting 멤버 변수를 초기화
function setGreeting(string memory _greeting) public {
greeting = _greeting;
}
// greeting 을 반환
function say() public view returns(string memory) {
return greeting;
}
}
pragma solidity ^0.4.8;
contract Yes24Coin {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
// Event
event Transfer(address indexed from, address indexed to, uint256 value);
// Constructor
function Yes24Coin(uint256 _supply, string _name, string _symbol, uint8 _decimals) {
balanceOf[msg.sender] = _supply;
name = _name;
symbol = _symbol;
decimals = _decimals;
totalSupply = _supply;
}
function transfer(address _to, uint256 _value) {
// Check
if (balanceOf[msg.sender] < _value) throw;
if (balanceOf[_to] + _value < balanceOf[_to]) throw;
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment