Successfully reported this slideshow.
Your SlideShare is downloading. ×

Smart contract and Solidity

Ad

Smart Contract & Solidity
Solidity
winterj.me@gmail.com
JungWinter

Ad

Smart Contract

Ad

Smart Contract
• 

• 1994 Nick Szabo

• 

• 



Transaction 


Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Upcoming SlideShare
Solidity Simple Tutorial EN
Solidity Simple Tutorial EN
Loading in …3
×

Check these out next

1 of 27 Ad
1 of 27 Ad

Smart contract and Solidity

Download to read offline

스마트 컨트랙트에 관한 개요와 이더리움의 스마트 컨트랙트 코드를 작성할 수 있는 Solidity에 대해 코드를 통해 알아보는 슬라이드입니다.

스마트 컨트랙트에 관한 개요와 이더리움의 스마트 컨트랙트 코드를 작성할 수 있는 Solidity에 대해 코드를 통해 알아보는 슬라이드입니다.

Advertisement
Advertisement

More Related Content

Similar to Smart contract and Solidity (20)

Advertisement

Smart contract and Solidity

  1. 1. Smart Contract & Solidity Solidity winterj.me@gmail.com JungWinter
  2. 2. Smart Contract
  3. 3. Smart Contract • • 1994 Nick Szabo • • 
 
 Transaction 

  4. 4. Smart Contract
  5. 5. • 
 • •
  6. 6. • • Contacting external services, Enforcing on-chain payments • (= )
  7. 7. Ethereum Contract
  8. 8. Bitcoin Contract • Script • OPCODE • Output Input Public Key  HASH  CHECKSIG  Private Key TRUE
  9. 9. Ethereum Contract •  Turing Complete • APPLY(S)=S’ 
 (APPLY: , S: , S’: ) • Smart Contract • Loop , Contract Account, Block Transaction , Gas
  10. 10. Loop Gas • Operation Gas Cost • Transaction fee = Gas_used * Gas_price[Gwei]
 1 Gwei = 0.000000001 ETH • Gas 
 = Gas
  11. 11. Smart Contract Code • Smart Contract 
 Smart Contract Code • EVM(Ethereum Virtual Machine) 
 EVM • • Mutan: C Deprecated • LLL: Low level OPCODE • Serpent: Python • Solidity: Javascript
  12. 12. Smart Contract (https://maniara.github.io/sc_lecture.pdf)
  13. 13. Solidity
  14. 14. Solidity Hello World pragma solidity ^0.4.0; contract SimpleStorage { uint storedData; function set(uint x) { storedData = x; } function get() constant returns (uint retVal) { return storedData; } } pragma constant returns uint http://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html
  15. 15. Solidity Hello World pragma solidity ^0.4.0; contract SimpleStorage { uint storedData; function set(uint x) { storedData = x; } function get() constant returns (uint retVal) { return storedData; } } pragma constant returns uint ^0.4.0 Solidity 0.5.0 npm ^1.2.3 → >=1.2.3 <2.0.0 ^0.2.3 → >=0.2.3 <0.3.0 ^0.0.3 → >=0.0.3 <0.0.4
  16. 16. Solidity Hello World pragma solidity ^0.4.0; contract SimpleStorage { uint storedData; function set(uint x) { storedData = x; } function get() constant returns (uint retVal) { return storedData; } } pragma constant returns uint constant State constant Gas Modifier . 0.4.16 constant view pure constant view alias pure pure
  17. 17. Solidity Hello World pragma solidity ^0.4.0; contract SimpleStorage { uint storedData; function set(uint x) { storedData = x; } function get() constant returns (uint retVal) { return storedData; } } pragma constant returns uint return 1
  18. 18. Solidity Hello World pragma solidity ^0.4.0; contract SimpleStorage { uint storedData; function set(uint x) { storedData = x; } function get() constant returns (uint retVal) { return storedData; } } pragma constant returns uint uint unsigned int uint8 uint256 uint uint256
  19. 19. Solidity Code → Byte Code SMART CONTRACT (http://goodjoon.tistory.com/261)
  20. 20. SMART CONTRACT (http://goodjoon.tistory.com/261) dApp Contract Meta data
  21. 21. pragma solidity ^0.4.0; contract Coin{ address public minter; mapping (address => uint ) public balances; event Sent (address from, address to, uint amount); function Coin() { minter = msg.sender; } function mint(address receiver, uint amount) { if (msg.sender != minter) return; balances[receiver] += amount; } function send(address receiver, uint amount) { if (balances[msg.sender] < amount) return; balances[msg.sender] -= amount; balances[receiver] += amount; Sent(msg.sender, receiver, amount); } } http://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html address public mapping event msg
  22. 22. address public mapping event msg http://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html 20byte( ) balance( ), transfer( ) Python dict . mapping(address => uint) address key uint value dict public address public minter; function minter() returns (address) { return minter; } ), msg.sender , msg.value Wei(Ether) 
 .data, .gas, .sig . listener
  23. 23. (3)—   (https://medium.com/@soonhyungjung/ - - -3- - - -44a9d58d687a)
  24. 24. pragma solidity^0.4.0; contract Bank { uint totalDeposit; mapping(address=> uint) balanceOf; function deposit() payable { balanceOf[msg.sender] += msg.value; totalDeposit += msg.value; } function withdraw(uint _amount) payable { balanceOf[msg.sender] -= _amount; totalDeposit -= _amount; msg.sender.call.value(_amount)(); // msg.sender.transfer(_amount); } function getTotalBalance() constant returns(uint) { return totalDeposit; } function getBalance(address _account) constant returns(uint) { return balanceOf[_account]; } } payable
  25. 25. payable & modifier pragma solidity ^0.4.11; contract Purchase { address public seller; modifier onlySeller() { // Modifier require(msg.sender == seller); _; } function abort() onlySeller { // Modifier usage // ... } } Solidity modifier  payable (https://medium.com/@ggogun/solidity -modifier- -payable-d892a833920c) Python Decorator, Ruby on Rails before_filter _; modifier .
  26. 26. TODO • Solidity Voting • Campaign & Crowdfunding • Custom Token
  27. 27. • Why Many Smart Contract Use Cases Are Simply Impossible (https:// www.coindesk.com/three-smart-contract-misconceptions/) • Calculating Costs in Ethereum Contracts (https://hackernoon.com/ether-purchase- power-df40a38c5a2f) • Gas Cost from Yellow Paper (http://bit.ly/2xfBHWN) • SMART CONTRACT - (http://goodjoon.tistory.com/253) • SMART CONTRACT (http://goodjoon.tistory.com/261) • dApp (http://www.chaintalk.io/archive/lecture/86) • Solidity (https://www.gitbook.com/book/ggs134/solidityguide) • Solidity (https://solidity.readthedocs.io/en/develop/)

×