SlideShare a Scribd company logo
1 of 27
Download to read offline
Smart Contract & Solidity
Solidity
winterj.me@gmail.com
JungWinter
Smart Contract
Smart Contract
• 

• 1994 Nick Szabo

• 

• 



Transaction 

Smart Contract
• 



• 

•
•


• Contacting external services, Enforcing on-chain
payments 

• (= )
Ethereum Contract
Bitcoin Contract
• Script 

• OPCODE 

• Output Input Public Key  HASH
 CHECKSIG  Private Key TRUE
Ethereum Contract
•
 Turing Complete 

• APPLY(S)=S’ 

(APPLY: , S: , S’: )

• Smart Contract

• Loop , Contract Account, Block Transaction
, Gas
Loop Gas
• Operation Gas Cost 

• Transaction fee = Gas_used * Gas_price[Gwei]

1 Gwei = 0.000000001 ETH

• Gas 

= Gas
Smart Contract Code
• Smart Contract 

Smart Contract Code 

• EVM(Ethereum Virtual Machine) 

EVM 

• 

• Mutan: C Deprecated

• LLL: Low level OPCODE

• Serpent: Python 

• Solidity: Javascript
Smart Contract
(https://maniara.github.io/sc_lecture.pdf)
Solidity
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
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
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
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
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
Solidity Code → Byte Code
SMART CONTRACT (http://goodjoon.tistory.com/261)
SMART CONTRACT (http://goodjoon.tistory.com/261)
dApp
Contract Meta data
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
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
(3)—   

(https://medium.com/@soonhyungjung/ - - -3- - - -44a9d58d687a)
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
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 .
TODO
• Solidity Voting 

• Campaign & Crowdfunding 

• Custom Token
• 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/)

More Related Content

What's hot

Accessing decentralized finance on Ethereum blockchain
Accessing decentralized finance on Ethereum blockchainAccessing decentralized finance on Ethereum blockchain
Accessing decentralized finance on Ethereum blockchainGene Leybzon
 
Smart Contracts with Solidity hands-on training session
Smart Contracts with Solidity hands-on training session  Smart Contracts with Solidity hands-on training session
Smart Contracts with Solidity hands-on training session Gene Leybzon
 
Hello world contract
Hello world contractHello world contract
Hello world contractGene Leybzon
 
Solidity Security and Best Coding Practices
Solidity Security and Best Coding PracticesSolidity Security and Best Coding Practices
Solidity Security and Best Coding PracticesGene Leybzon
 
Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3Gene Leybzon
 
Blockchain and smart contracts day 2
Blockchain and smart contracts day 2Blockchain and smart contracts day 2
Blockchain and smart contracts day 2Gene Leybzon
 
Libbitcoin slides
Libbitcoin slidesLibbitcoin slides
Libbitcoin slidesswansontec
 
Meteor and Bitcoin (Lightning Talk)
Meteor and Bitcoin (Lightning Talk)Meteor and Bitcoin (Lightning Talk)
Meteor and Bitcoin (Lightning Talk)Ryan Casey
 
Principais vulnerabilidades em Smart Contracts e como evitá-las
Principais vulnerabilidades em Smart Contracts e como evitá-lasPrincipais vulnerabilidades em Smart Contracts e como evitá-las
Principais vulnerabilidades em Smart Contracts e como evitá-lasJúlio Campos
 
Js interpreter interpreted
Js interpreter interpretedJs interpreter interpreted
Js interpreter interpretedMartha Schumann
 
The Ring programming language version 1.6 book - Part 25 of 189
The Ring programming language version 1.6 book - Part 25 of 189The Ring programming language version 1.6 book - Part 25 of 189
The Ring programming language version 1.6 book - Part 25 of 189Mahmoud Samir Fayed
 
05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics05 - Qt External Interaction and Graphics
05 - Qt External Interaction and GraphicsAndreas Jakl
 
Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223Jarmo van de Seijp
 
Qtum How To Make EVM Run On UTXO Model - Patrick Dai
Qtum How To Make EVM Run On UTXO Model - Patrick DaiQtum How To Make EVM Run On UTXO Model - Patrick Dai
Qtum How To Make EVM Run On UTXO Model - Patrick DaiQtum
 
The Ring programming language version 1.5.3 book - Part 92 of 184
The Ring programming language version 1.5.3 book - Part 92 of 184The Ring programming language version 1.5.3 book - Part 92 of 184
The Ring programming language version 1.5.3 book - Part 92 of 184Mahmoud Samir Fayed
 

What's hot (20)

Accessing decentralized finance on Ethereum blockchain
Accessing decentralized finance on Ethereum blockchainAccessing decentralized finance on Ethereum blockchain
Accessing decentralized finance on Ethereum blockchain
 
Smart Contracts with Solidity hands-on training session
Smart Contracts with Solidity hands-on training session  Smart Contracts with Solidity hands-on training session
Smart Contracts with Solidity hands-on training session
 
Hello world contract
Hello world contractHello world contract
Hello world contract
 
Solidity Security and Best Coding Practices
Solidity Security and Best Coding PracticesSolidity Security and Best Coding Practices
Solidity Security and Best Coding Practices
 
Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3
 
Blockchain and smart contracts day 2
Blockchain and smart contracts day 2Blockchain and smart contracts day 2
Blockchain and smart contracts day 2
 
Oop1
Oop1Oop1
Oop1
 
Libbitcoin slides
Libbitcoin slidesLibbitcoin slides
Libbitcoin slides
 
Oop lab report
Oop lab reportOop lab report
Oop lab report
 
Meteor and Bitcoin (Lightning Talk)
Meteor and Bitcoin (Lightning Talk)Meteor and Bitcoin (Lightning Talk)
Meteor and Bitcoin (Lightning Talk)
 
Principais vulnerabilidades em Smart Contracts e como evitá-las
Principais vulnerabilidades em Smart Contracts e como evitá-lasPrincipais vulnerabilidades em Smart Contracts e como evitá-las
Principais vulnerabilidades em Smart Contracts e como evitá-las
 
Textile
TextileTextile
Textile
 
Js interpreter interpreted
Js interpreter interpretedJs interpreter interpreted
Js interpreter interpreted
 
Advanced smart contract
Advanced smart contractAdvanced smart contract
Advanced smart contract
 
Oracles
OraclesOracles
Oracles
 
The Ring programming language version 1.6 book - Part 25 of 189
The Ring programming language version 1.6 book - Part 25 of 189The Ring programming language version 1.6 book - Part 25 of 189
The Ring programming language version 1.6 book - Part 25 of 189
 
05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics
 
Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223
 
Qtum How To Make EVM Run On UTXO Model - Patrick Dai
Qtum How To Make EVM Run On UTXO Model - Patrick DaiQtum How To Make EVM Run On UTXO Model - Patrick Dai
Qtum How To Make EVM Run On UTXO Model - Patrick Dai
 
The Ring programming language version 1.5.3 book - Part 92 of 184
The Ring programming language version 1.5.3 book - Part 92 of 184The Ring programming language version 1.5.3 book - Part 92 of 184
The Ring programming language version 1.5.3 book - Part 92 of 184
 

Similar to Smart contract and Solidity

How to be a smart contract engineer
How to be a smart contract engineerHow to be a smart contract engineer
How to be a smart contract engineerOded Noam
 
“Create your own cryptocurrency in an hour” - Sandip Pandey
“Create your own cryptocurrency in an hour” - Sandip Pandey“Create your own cryptocurrency in an hour” - Sandip Pandey
“Create your own cryptocurrency in an hour” - Sandip PandeyEIT Digital Alumni
 
Droid on Chain - Berry Ventura Lev, Kik
Droid on Chain - Berry Ventura Lev, KikDroid on Chain - Berry Ventura Lev, Kik
Droid on Chain - Berry Ventura Lev, KikDroidConTLV
 
Robust Programming of Smart Contracts in Solidity+, RK Shyamasundar
Robust Programming of Smart Contracts in Solidity+, RK ShyamasundarRobust Programming of Smart Contracts in Solidity+, RK Shyamasundar
Robust Programming of Smart Contracts in Solidity+, RK ShyamasundarNapier University
 
First impression of the new cloud native programming language ballerina
First impression of the new cloud native programming language ballerinaFirst impression of the new cloud native programming language ballerina
First impression of the new cloud native programming language ballerinaRichárd Kovács
 
Security in the blockchain
Security in the blockchainSecurity in the blockchain
Security in the blockchainBellaj Badr
 
Understanding Algorand's smart contract language
Understanding Algorand's smart contract language   Understanding Algorand's smart contract language
Understanding Algorand's smart contract language Vanessa Lošić
 
Ethereum: Coding Society
Ethereum: Coding SocietyEthereum: Coding Society
Ethereum: Coding Societygavofyork
 
Ethereum hackers
Ethereum hackersEthereum hackers
Ethereum hackersgavofyork
 
Token platform based on sidechain
Token platform based on sidechainToken platform based on sidechain
Token platform based on sidechainLuniverse Dunamu
 
A Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts BytecodeA Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts BytecodeShakacon
 
用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構Bo-Yi Wu
 
Use Geth to Access a Deployed Contract
Use Geth to Access a Deployed ContractUse Geth to Access a Deployed Contract
Use Geth to Access a Deployed ContractKC Tam
 
solc-verify: A Modular Verifier for Solidity Smart Contracts
solc-verify: A Modular Verifier for Solidity Smart Contractssolc-verify: A Modular Verifier for Solidity Smart Contracts
solc-verify: A Modular Verifier for Solidity Smart ContractsAkos Hajdu
 
ERC20 Token Contract
ERC20 Token ContractERC20 Token Contract
ERC20 Token ContractKC Tam
 
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereumDappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereumTomoaki Sato
 
Programming smart contracts in solidity
Programming smart contracts in solidityProgramming smart contracts in solidity
Programming smart contracts in solidityEmanuel Mota
 
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...GeeksLab Odessa
 

Similar to Smart contract and Solidity (20)

How to be a smart contract engineer
How to be a smart contract engineerHow to be a smart contract engineer
How to be a smart contract engineer
 
“Create your own cryptocurrency in an hour” - Sandip Pandey
“Create your own cryptocurrency in an hour” - Sandip Pandey“Create your own cryptocurrency in an hour” - Sandip Pandey
“Create your own cryptocurrency in an hour” - Sandip Pandey
 
Droid on Chain - Berry Ventura Lev, Kik
Droid on Chain - Berry Ventura Lev, KikDroid on Chain - Berry Ventura Lev, Kik
Droid on Chain - Berry Ventura Lev, Kik
 
Robust Programming of Smart Contracts in Solidity+, RK Shyamasundar
Robust Programming of Smart Contracts in Solidity+, RK ShyamasundarRobust Programming of Smart Contracts in Solidity+, RK Shyamasundar
Robust Programming of Smart Contracts in Solidity+, RK Shyamasundar
 
First impression of the new cloud native programming language ballerina
First impression of the new cloud native programming language ballerinaFirst impression of the new cloud native programming language ballerina
First impression of the new cloud native programming language ballerina
 
Security in the blockchain
Security in the blockchainSecurity in the blockchain
Security in the blockchain
 
Understanding Algorand's smart contract language
Understanding Algorand's smart contract language   Understanding Algorand's smart contract language
Understanding Algorand's smart contract language
 
Ethereum: Coding Society
Ethereum: Coding SocietyEthereum: Coding Society
Ethereum: Coding Society
 
Ethereum hackers
Ethereum hackersEthereum hackers
Ethereum hackers
 
Geth important commands
Geth important commandsGeth important commands
Geth important commands
 
Token platform based on sidechain
Token platform based on sidechainToken platform based on sidechain
Token platform based on sidechain
 
A Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts BytecodeA Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts Bytecode
 
C sharp 8
C sharp 8C sharp 8
C sharp 8
 
用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構
 
Use Geth to Access a Deployed Contract
Use Geth to Access a Deployed ContractUse Geth to Access a Deployed Contract
Use Geth to Access a Deployed Contract
 
solc-verify: A Modular Verifier for Solidity Smart Contracts
solc-verify: A Modular Verifier for Solidity Smart Contractssolc-verify: A Modular Verifier for Solidity Smart Contracts
solc-verify: A Modular Verifier for Solidity Smart Contracts
 
ERC20 Token Contract
ERC20 Token ContractERC20 Token Contract
ERC20 Token Contract
 
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereumDappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
 
Programming smart contracts in solidity
Programming smart contracts in solidityProgramming smart contracts in solidity
Programming smart contracts in solidity
 
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
 

Recently uploaded

Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Recently uploaded (20)

Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

Smart contract and Solidity

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

  • 6. • • Contacting external services, Enforcing on-chain payments • (= )
  • 8. Bitcoin Contract • Script • OPCODE • Output Input Public Key  HASH  CHECKSIG  Private Key TRUE
  • 9. Ethereum Contract •  Turing Complete • APPLY(S)=S’ 
 (APPLY: , S: , S’: ) • Smart Contract • Loop , Contract Account, Block Transaction , Gas
  • 10. Loop Gas • Operation Gas Cost • Transaction fee = Gas_used * Gas_price[Gwei]
 1 Gwei = 0.000000001 ETH • Gas 
 = Gas
  • 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
  • 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. 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. 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. 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. 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. Solidity Code → Byte Code SMART CONTRACT (http://goodjoon.tistory.com/261)
  • 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. 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. (3)—   (https://medium.com/@soonhyungjung/ - - -3- - - -44a9d58d687a)
  • 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. 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. TODO • Solidity Voting • Campaign & Crowdfunding • Custom Token
  • 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/)