SlideShare a Scribd company logo
Solidity 
What and Why
Problem 
Need people to write contracts. 
Correct contracts. 
Lots of people.
Solutions 
Tend to be Web devs 
Syntax similar to JavaScript 
...to minimise barriers to entry and leverage existing skillset
Solutions 
Express common concepts clearly 
First-class contracts as classes 
...for transparent integration and reuse 
Storage constructs 
...for ease of contract STORE usage 
Variadic returns 
...for ease of contract RETURN passing
Solutions 
Make things likely to be correct 
Unit tests 
...that are easier to use than not 
Formal proofing 
...that makes statements guaranteed always true
Solutions 
Documentation fundamental 
Inbuilt documentation system 
(See later talk)
Contracts as first-class citizens 
contract StoreNumber { 
void set(uint n) { ... } 
uint get() const { ... } 
... 
} 
contract Other { 
Other() { 
StoreNumber s = ...; 
s.set(69); 
... 
uint n = s.get(); 
} 
}
(Easy) Storage Facilities 
contract StoreNumber { 
function set(uint n) { m_n = n; } 
function get() const returns (uint) { 
return m_n; 
} 
uint m_n; 
}
(Easy) Storage Facilities 
struct Endpoint { 
uint32 ipv4; 
uint16 port; 
} 
contract Endpoints { 
function set(uint32 _ipv4, uint16 _port) { 
var end = new Endpoint({ipv4: _ipv4, port: 
_port}); 
m_ends[msg.caller] = end; 
} 
function kill() { delete m_ends[msg.caller]; } 
mapping { address => Endpoint } m_ends; 
}
Variadic Returns 
contract Endpoints { 
function set(uint32 _ipv4, uint16 _port) { 
var end = new Endpoint({ipv4: _ipv4, port: 
_port}); 
m_ends[msg.caller] = end; 
} 
function kill() { delete m_ends[msg.caller]; } 
function get(address _a) const 
returns (uint32, uint16) { 
return m_ends[_a]; 
} 
mapping { address => Endpoint } m_ends; 
}
Formal Proofing 
contract Cash { 
function give(address _a, uint32 _amount) { 
if (m_balances[msg.caller] >= _amount) { 
m_balances[msg.caller] -= _amount; 
m_balances[_a] += _amount; 
} 
} 
function balance(address _a) const returns (uint32) 
{ 
return m_balances[_a]; 
} 
mapping { address => uint64 } m_balances; 
construction: 
m_balances[msg.caller] = 1000000000; 
invariant: 
reduce(+, map(valueOf, m_balances)) == 1000000000; 
}
Inbuilt Docs (NatSpec) 
contract Cash { 
/// Transfers `_amount` cash from your account 
/// `msg.caller` to the account controlled by `_a`. 
function give(address _a, uint32 _amount) { 
if (m_balances[msg.caller] >= _amount) { 
m_balances[msg.caller] -= _amount; 
m_balances[_a] += _amount; 
} 
} 
/// Returns the amount of cash controlled by account 
/// `_a`. 
function balance(address _a) const returns (uint32) 
{ 
return m_balances[_a]; 
} 
mapping { address => uint64 } m_balances; 
construction: 
/// Creator of contract is endowed with balance of 
/// 1000000000. 
m_balances[msg.caller] = 1000000000; 
invariant: 
/// Total cash in system is always 1000000000. 
reduce(+, map(valueOf, m_balances)) == 1000000000; 
}
Solidity 
What and Why 
Over to Christian

More Related Content

PDF
Ethereum-Cryptocurrency (All about Ethereum)
PPTX
Write smart contract with solidity on Ethereum
PDF
Programming smart contracts in solidity
PPTX
Ethereum
PPTX
Smart Contract & Ethereum
PPTX
Learning Solidity
PDF
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Ethereum-Cryptocurrency (All about Ethereum)
Write smart contract with solidity on Ethereum
Programming smart contracts in solidity
Ethereum
Smart Contract & Ethereum
Learning Solidity
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...

What's hot (20)

PDF
Introduction to Blockchain
PDF
Smart Contracts Programming Tutorial | Solidity Programming Language | Solidi...
PPTX
Introduction to Blockchain
PPTX
Blockchain
PPTX
Blockchain
PPTX
Introduction to Blockchain and Smart Contracts
PDF
Blockchain Presentation
PDF
Blockchain 101 | Blockchain Tutorial | Blockchain Smart Contracts | Blockchai...
PPTX
Blockchain ppt
PDF
An Introduction to Blockchain Technology
PDF
Blockchain
PPTX
Blockchain Technology
PPTX
Hyperledger Fabric
PPTX
Blockchain Interview Questions And Answers | Blockchain Technology Interview ...
PDF
Ethereum in a nutshell
PPTX
Blockchain concepts
PPTX
Block chain technology and its applications
PPTX
What's cryptocurrency ?
PDF
Tmc mastering bitcoins ppt
Introduction to Blockchain
Smart Contracts Programming Tutorial | Solidity Programming Language | Solidi...
Introduction to Blockchain
Blockchain
Blockchain
Introduction to Blockchain and Smart Contracts
Blockchain Presentation
Blockchain 101 | Blockchain Tutorial | Blockchain Smart Contracts | Blockchai...
Blockchain ppt
An Introduction to Blockchain Technology
Blockchain
Blockchain Technology
Hyperledger Fabric
Blockchain Interview Questions And Answers | Blockchain Technology Interview ...
Ethereum in a nutshell
Blockchain concepts
Block chain technology and its applications
What's cryptocurrency ?
Tmc mastering bitcoins ppt
Ad

Viewers also liked (20)

PDF
Ethereum Contracts - Coinfest 2015
PPTX
Solidity Simple Tutorial EN
PDF
Smart contracts in Solidity
PDF
Ethereum: Next steps...
PPTX
Bazaar services
PDF
Crypto-law
PDF
Relative truth
PDF
Allegality
PDF
Polkadot prezo
PPTX
ÐΞVcon: Introduction
PDF
The world computer general
PDF
The world computer (short)
PDF
Blockchain what and why-
PDF
So now we've built Ethereum, WTF is it?
PDF
Where can smart contracts take us?
PPTX
Conceptualizing Smart Contracts
PDF
Blockchain, ethereum and polkadot
PDF
Ethereum: From there to here, and ownards yonder
PDF
Blockchain - Introduction and Authoring Smart Contracts
PDF
Basic ethereum
Ethereum Contracts - Coinfest 2015
Solidity Simple Tutorial EN
Smart contracts in Solidity
Ethereum: Next steps...
Bazaar services
Crypto-law
Relative truth
Allegality
Polkadot prezo
ÐΞVcon: Introduction
The world computer general
The world computer (short)
Blockchain what and why-
So now we've built Ethereum, WTF is it?
Where can smart contracts take us?
Conceptualizing Smart Contracts
Blockchain, ethereum and polkadot
Ethereum: From there to here, and ownards yonder
Blockchain - Introduction and Authoring Smart Contracts
Basic ethereum
Ad

Similar to Solidity (20)

PPTX
Smart Contract programming 101 with Solidity #PizzaHackathon
PPTX
Robust Programming of Smart Contracts in Solidity+, RK Shyamasundar
PDF
ERC20 Token Contract
PDF
Solidity and Ethereum Smart Contract Gas Optimization
PPTX
solc-verify: A Modular Verifier for Solidity Smart Contracts
PPTX
Ethereum
 
PDF
Solidity programming language and its different concepts with an example
DOCX
solidity programming solidity programming
PPTX
Hello world contract
PDF
Blockchain Programming
PPTX
Smart Contracts with Solidity hands-on training session
PDF
How to be a smart contract engineer
PPTX
solidity programming.pptx
PPTX
Ethereum.pptx
PPTX
Hands on with smart contracts
PPTX
Hands on with smart contracts
PPTX
Blockchain Blockchain Blockchain Lec 2.1.pptx
PPTX
Solidity Security and Best Coding Practices
PDF
Smart Contract Security
PPTX
Hands on with smart contracts 2. Presentation for the Blockchain Applications...
Smart Contract programming 101 with Solidity #PizzaHackathon
Robust Programming of Smart Contracts in Solidity+, RK Shyamasundar
ERC20 Token Contract
Solidity and Ethereum Smart Contract Gas Optimization
solc-verify: A Modular Verifier for Solidity Smart Contracts
Ethereum
 
Solidity programming language and its different concepts with an example
solidity programming solidity programming
Hello world contract
Blockchain Programming
Smart Contracts with Solidity hands-on training session
How to be a smart contract engineer
solidity programming.pptx
Ethereum.pptx
Hands on with smart contracts
Hands on with smart contracts
Blockchain Blockchain Blockchain Lec 2.1.pptx
Solidity Security and Best Coding Practices
Smart Contract Security
Hands on with smart contracts 2. Presentation for the Blockchain Applications...

More from gavofyork (12)

PDF
Governance in Polkadot PoC-3
PDF
Polkadot, Substrate and Governance (PoC-3)
PDF
Polkadot Presentation
PDF
Parity Progress Report
PDF
The world computer
PPTX
The Ethereum ÐApp IDE: Mix
PPTX
Whisper
PPTX
Ethereum: Coding Society
PDF
Ethereum hackers
PDF
The Ethereum Experience
PDF
Academic Ethereum
PDF
Berlinbetahaus
Governance in Polkadot PoC-3
Polkadot, Substrate and Governance (PoC-3)
Polkadot Presentation
Parity Progress Report
The world computer
The Ethereum ÐApp IDE: Mix
Whisper
Ethereum: Coding Society
Ethereum hackers
The Ethereum Experience
Academic Ethereum
Berlinbetahaus

Recently uploaded (20)

PDF
Website Design Services for Small Businesses.pdf
PPTX
assetexplorer- product-overview - presentation
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PPTX
GSA Content Generator Crack (2025 Latest)
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PDF
Salesforce Agentforce AI Implementation.pdf
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Types of Token_ From Utility to Security.pdf
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PPTX
Trending Python Topics for Data Visualization in 2025
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Time Tracking Features That Teams and Organizations Actually Need
PDF
STL Containers in C++ : Sequence Container : Vector
PPTX
Cybersecurity: Protecting the Digital World
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
Website Design Services for Small Businesses.pdf
assetexplorer- product-overview - presentation
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
GSA Content Generator Crack (2025 Latest)
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Salesforce Agentforce AI Implementation.pdf
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Digital Systems & Binary Numbers (comprehensive )
Types of Token_ From Utility to Security.pdf
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
Patient Appointment Booking in Odoo with online payment
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
Trending Python Topics for Data Visualization in 2025
Computer Software and OS of computer science of grade 11.pptx
Time Tracking Features That Teams and Organizations Actually Need
STL Containers in C++ : Sequence Container : Vector
Cybersecurity: Protecting the Digital World
Oracle Fusion HCM Cloud Demo for Beginners

Solidity

  • 2. Problem Need people to write contracts. Correct contracts. Lots of people.
  • 3. Solutions Tend to be Web devs Syntax similar to JavaScript ...to minimise barriers to entry and leverage existing skillset
  • 4. Solutions Express common concepts clearly First-class contracts as classes ...for transparent integration and reuse Storage constructs ...for ease of contract STORE usage Variadic returns ...for ease of contract RETURN passing
  • 5. Solutions Make things likely to be correct Unit tests ...that are easier to use than not Formal proofing ...that makes statements guaranteed always true
  • 6. Solutions Documentation fundamental Inbuilt documentation system (See later talk)
  • 7. Contracts as first-class citizens contract StoreNumber { void set(uint n) { ... } uint get() const { ... } ... } contract Other { Other() { StoreNumber s = ...; s.set(69); ... uint n = s.get(); } }
  • 8. (Easy) Storage Facilities contract StoreNumber { function set(uint n) { m_n = n; } function get() const returns (uint) { return m_n; } uint m_n; }
  • 9. (Easy) Storage Facilities struct Endpoint { uint32 ipv4; uint16 port; } contract Endpoints { function set(uint32 _ipv4, uint16 _port) { var end = new Endpoint({ipv4: _ipv4, port: _port}); m_ends[msg.caller] = end; } function kill() { delete m_ends[msg.caller]; } mapping { address => Endpoint } m_ends; }
  • 10. Variadic Returns contract Endpoints { function set(uint32 _ipv4, uint16 _port) { var end = new Endpoint({ipv4: _ipv4, port: _port}); m_ends[msg.caller] = end; } function kill() { delete m_ends[msg.caller]; } function get(address _a) const returns (uint32, uint16) { return m_ends[_a]; } mapping { address => Endpoint } m_ends; }
  • 11. Formal Proofing contract Cash { function give(address _a, uint32 _amount) { if (m_balances[msg.caller] >= _amount) { m_balances[msg.caller] -= _amount; m_balances[_a] += _amount; } } function balance(address _a) const returns (uint32) { return m_balances[_a]; } mapping { address => uint64 } m_balances; construction: m_balances[msg.caller] = 1000000000; invariant: reduce(+, map(valueOf, m_balances)) == 1000000000; }
  • 12. Inbuilt Docs (NatSpec) contract Cash { /// Transfers `_amount` cash from your account /// `msg.caller` to the account controlled by `_a`. function give(address _a, uint32 _amount) { if (m_balances[msg.caller] >= _amount) { m_balances[msg.caller] -= _amount; m_balances[_a] += _amount; } } /// Returns the amount of cash controlled by account /// `_a`. function balance(address _a) const returns (uint32) { return m_balances[_a]; } mapping { address => uint64 } m_balances; construction: /// Creator of contract is endowed with balance of /// 1000000000. m_balances[msg.caller] = 1000000000; invariant: /// Total cash in system is always 1000000000. reduce(+, map(valueOf, m_balances)) == 1000000000; }
  • 13. Solidity What and Why Over to Christian