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

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

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/)