SlideShare a Scribd company logo
“HELLO WORLD” SMART
CONTRACT
Hands-on introduction to
the world of Solidity and
Smart contract
programming on Ethereum
PLAN FOR TODAY
Blockchain introduction for Engineers
Understand basis Etherium concepts
Selenium Language
Create your first contract
Compile
Test
BLOCKCHAIN
INTRODUCTION
• Why?
• What?
• How?
WHY BLOCKCHAIN IS A BIG DEAL
“Bitcoin is a technological tour de force.”
– Bill Gates
”I think the fact that within the bitcoin universe an algorithm replaces
the function of the government …[that] is actually pretty cool.”
- Al Gore
“[Bitcoin] is a remarkable cryptographic achievement… The ability to
create something which is not duplicable in the digital world has
enormous value…Lot’s of people will build businesses on top of that.”
- Eric Schmidt
BLOCKCHAIN IS
Ledger of facts
Ledger of facts replicated across large number of
computers
Ledger of facts replicated across large number of
computers connected as peer-to-peer network
Ledger of facts replicated across large number of
computers connected as peer-to-peer network that
implements consensus algorithm that can securely
identify sender and receiver of facts
FACT
S
Monetary
transactio
n
Content
hash
Signature
Asset
informatio
n
Ownership
Agreemen
t
Contract
IS IT JUST ANOTHER SHARED
DATABASE?
NOT JUST ANOTHER
DATABASE
Multiple
Writers
Non-trusting
writers
Disintermediati
on
Interaction
between
transactions
Conflict
resolution
Blockchain is a source of truth
Blockchain Use Cases
HOW?
Blocks
Decentralized consensus
Byzantine fault tolerance.
CHAIN OF TRANSACTIONS
TIMESTAMPS
Introduction to
Smart Contracts
Smart Contract Definition
Smart contract are
applications that run
exactly as programmed
without any possibility of
downtime, censorship,
fraud or third party
interference.
EXAMPLE OF A CONTRACT
EXAMPLE OF SMART
CONTRACT (TOKENS)
CONCEPTS
• Accounts
• Contracts
• Messages
TWO TYPES OF ACCOUNTS
Account
StorageBalance Code
<>
Externally Owned Account
StorageBalance
Account
StorageBalance Code
<>
Contract
StorageBalance Code
<>
CONTRACTS
Contracts are accounts that contain
code
Store the state
• Example:
keeps account
balance
Source of
notifications
(events)
• Example:
messaging
service that
forwards only
messages when
certain
conditions are
met
Mapping -
relationship
between users
• Example:
mapping real-
world financial
contract to
Etherium
contract
Act like a
software library
• Example:
return
calculated value
based on
message
arguments
CALLS AND MESSAGES
Contract A Contract B
Message Call
• Source
• Target
• Data Payload
• Ether
• Gas
• Return Data
Externally
owned
account
Message CallSend Transaction
Call
WHAT CONTRACT CAN DO?
Read internal state
contract
ReadStateDemo {
uint public state;
function read() {
console.log(“State:
"+state);
}
}
Modify internal
State
contract
ModStateDemo {
uint public state;
function update() {
state=state+1;
}
}
Consume message
contract
ReadStateDemo {
uint public state;
function hi() {
console.log(“Hello
from: “
"+msg.sender + “
to “ + msg.
receiver);
}
}
Trigger execution
of another contract
contract CallDemo {
function
send(address
receiver, uint
amount) public {
Sent(msg.sender,
receiver, amount);
}
}
CONTRACT LANGUAGES
Solidity
Serpent
LLL
Bytecodes
Etherium Virtual
Machine (EVM)
REGISTRARS (ETHEREUM NAME SERVICE, ENS)
1. Send ether to an address in
Metamask (soon: MEW, Mist, Bitfinex)
1. Use it inside your own contracts to
resolve names of other contracts and
addresses
2. Store contract ABIs for easy lookup
using the ethereum-ens library
3. Address of a Swarm site
Use Cases
Registry
Registar
Resolver
ETHER
• Wei: 1
• Ada: 1000
• Fentoether: 1000
• Kwei: 1,000
• Mwei: 1,000,000
• Babbage:
1,000,000
• Pictoether: 1,000,000
• Shannon: 1,000,000,000
• Gwei: 1,000,000,000
• Nano: 1,000,000,000
• Szabo: 1,000,000,000,000
• Micro: 1,000,000,000,000
• Microether: 1,000,000,000,000
• Finney: 1,000,000,000,000,000
• Milli: 1,000,000,000,000,000
• Milliether: 1,000,000,000,000,000
• Ether:
1,000,000,000,000,000,000
Wei = 10-18 Ether
GAS
step 1 Default amount of gas to pay for an execution
cycle
stop 0 Nothing paid for the STOP operation
suicide 0 Nothing paid for the SUICIDE operation
sha3 20 Paid for a SHA3 operation
sload 30 Paid for a SLOAD operation
sstore 100 Paid for a normal SSTORE operation
(doubled or waived sometimes)
balance 20 Paid for a BALANCE operation
create 100 Paid for a CREATE operation
call 20 Paid for a CALL operation
memory 1 Paid for every additional word when
expanding memory
txdata 5 Paid for every byte of data or code for a
transaction
Example:
300 CPU cycles = 300 gas units = 0.000006 ETH =
$0.00553
(as of 2/20/2018)
Cost of Gas as in 2018
TEST NETWORKS
Ropsten
Rinkeby
Kovan
2 MINUTE
INTRODUCTION TO
SOLIDITY
Data Types
Functions
ELEMENTARY DATA TYPES
Data Type Example
uint<M> , M=1,2,4, …, 256
int<M>, uint, int
Unsigned/signed integer uint256 counter = 1;
address 160-bit value that does not
allow any arithmetic
operations. It is suitable for
storing addresses of contracts
or keypairs belonging to
external persons
address owner = msg.sender;
bool Same as uint8 but values are 0
or 1
Bool b = 0;
fixed<M>x<N>
ufixed<M>x<N>
Signed fixed-point decimal
number of M bits
fixed128x19 f = 1.1;
bytes<M>, M=1..32 Binary of M bytes bytes32 n=123;
function Same as bytes24 Function f;
ARRAYS
Data Type Example
<type>[M] fixed-length array of fixed-
length type
byte[100]
<type>[] variable-length array of fixed-
length type
byte[]
bytes dynamic sized byte sequence bytes ab;
string dynamic sized Unicode string String s = “String”;
fixed<M>x<N>
ufixed<M>x<N>
Signed fixed-point decimal
number of M bits
fixed128x19 f = 1.1;
FUNCTIONS
Functio
ns
Consta
nt
Transactio
nal
Function Visibility
External Can be called via
transactions
Public Can be called via
messages or locally
Internal Only locally called or from
derived contracts
Private Locally called
pragma solidity^0.4.12;
contract Test {
function test(uint[20] a) public returns (uint){
return a[10]*2;
}
function test2(uint[20] a) external returns (uint){
return a[10]*2; }
}
}
HANDS-ON Code time
HELLO WORLD CONTRACT
(SOLIDITY CODE)
pragma solidity ^0.4.24;
contract Hello {
constructor() public {
// constructor
}
function sayHello() public pure returns (string) {
return 'Hello World!';
}
}
REMIX https://remix.ethereum.or
g/
REMIX https://remix.ethereum.or
g/
REMIX https://remix.ethereum.or
g/
SECOND CONTRACT
(COUNTING)
pragma solidity ^0.4.24;
contract Count {
uint public value = 0;
function plus() public returns
(uint) {
value++;
return value;
}
}
More Contracts to Work On
https://github.com/leybzon/solidity-
baby-steps/tree/master/contracts
TOKENS
• ERC20
• ERC223
• ERC721
ERC223 TOKEN
ERC223 is backwards compatible with ERC20
merges the token transfer function among wallets and contracts into one
single function ‘transfer()’
does not allow token to be transferred to a contract that does not allow
token to be withdrawn
Improvements with ERC223
• Eliminates the problem of lost tokens which happens during the transfer of ERC20 tokens to a contract
(when people mistakenly use the instructions for sending tokens to a wallet). ERC223 allows users to send
their tokens to either wallet or contract with the same function transfer, thereby eliminating the potential
for confusion and lost tokens.
• Allows developers to handle incoming token transactions, and reject non-supported tokens (not possible
with ERC20)
• Energy savings. The transfer of ERC223 tokens to a contract is a one step process rather than 2 step
process (for ERC20), and this means 2 times less gas and no extra blockchain bloating.
ERC223 TOKEN INTERFACE
contract ERC223 {
uint public totalSupply;
function balanceOf(address who) public view returns (uint);
function name() public view returns (string _name);
function symbol() public view returns (string _symbol);
function decimals() public view returns (uint8 _decimals);
function totalSupply() public view returns (uint256 _supply);
function transfer(address to, uint value) public returns (bool ok);
function transfer(address to, uint value, bytes data) public
returns (bool ok);
function transfer(address to, uint value, bytes data, string
custom_fallback) public returns (bool ok);
event Transfer(address indexed from, address indexed to, uint
value, bytes indexed data);
}
ERC721
▪People love collecting
▪Allow smart contracts to operate as tradable tokens
▪Each ERC721 is unique (non-fungible)
▪Support “ownership” functions
▪Each token is referenced by unique id
▪Tokens can have metadata (attributes)
ERC721
contract ERC721 {
event Transfer(address indexed _from, address indexed
_to, uint256 _tokenId);
event Approval(address indexed _owner, address indexed
_approved, uint256 _tokenId);
function balanceOf(address _owner) public view returns
(uint256 _balance);
function ownerOf(uint256 _tokenId) public view returns
(address _owner);
function transfer(address _to, uint256 _tokenId) public;
function approve(address _to, uint256 _tokenId) public;
function takeOwnership(uint256 _tokenId) public;
}
STAY IN
TOUCH
Gene Leybzon https://www.linkedin.com/in/leybzon/
https://www.meetup.com/Blockchain-
Applications-and-Smart-Contracts/
https://www.meetup.com/members/9074420/
https://www.leybzon.com
NEXT STEPS
http://solidity.readthedocs.ioLanguage
• Learn Solidity
Ideas
People
• Meetups
• Conferences

More Related Content

What's hot

Solidity Security and Best Coding Practices
Solidity Security and Best Coding PracticesSolidity Security and Best Coding Practices
Solidity Security and Best Coding Practices
Gene Leybzon
 
Blockchain and Smart Contracts
Blockchain and Smart ContractsBlockchain and Smart Contracts
Blockchain and Smart Contracts
Gene Leybzon
 
Solidity Simple Tutorial EN
Solidity Simple Tutorial ENSolidity Simple Tutorial EN
Solidity Simple Tutorial EN
Nicholas Lin
 
Blockchain Coding Dojo - BlockchainHub Graz
Blockchain Coding Dojo - BlockchainHub GrazBlockchain Coding Dojo - BlockchainHub Graz
Blockchain Coding Dojo - BlockchainHub Graz
BlockchainHub Graz
 
Ripple
RippleRipple
Ripple
Gene Leybzon
 
Smart Contract programming 101 with Solidity #PizzaHackathon
Smart Contract programming 101 with Solidity #PizzaHackathonSmart Contract programming 101 with Solidity #PizzaHackathon
Smart Contract programming 101 with Solidity #PizzaHackathon
Sittiphol Phanvilai
 
Ethereum Contracts - Coinfest 2015
Ethereum Contracts - Coinfest 2015Ethereum Contracts - Coinfest 2015
Ethereum Contracts - Coinfest 2015
Rhea Myers
 
Solidity
SoliditySolidity
Solidity
gavofyork
 
Smart contract and Solidity
Smart contract and SoliditySmart contract and Solidity
Smart contract and Solidity
겨울 정
 
“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
EIT Digital Alumni
 
ERC20 Token Contract
ERC20 Token ContractERC20 Token Contract
ERC20 Token Contract
KC Tam
 
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
병완 임
 
Smart contracts in Solidity
Smart contracts in SoliditySmart contracts in Solidity
Smart contracts in Solidity
Felix Crisan
 
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
Oded Noam
 
Oop1
Oop1Oop1
(18.03.2009) Cumuy Invita - Iniciando el año conociendo nuevas tecnologías - ...
(18.03.2009) Cumuy Invita - Iniciando el año conociendo nuevas tecnologías - ...(18.03.2009) Cumuy Invita - Iniciando el año conociendo nuevas tecnologías - ...
(18.03.2009) Cumuy Invita - Iniciando el año conociendo nuevas tecnologías - ...
Microsoft Argentina y Uruguay [Official Space]
 
Cyber Security
Cyber SecurityCyber Security
Cyber Security
amit bezalel
 
Ejemplos Programas Descompilados
Ejemplos Programas DescompiladosEjemplos Programas Descompilados
Ejemplos Programas Descompilados
Luis Viteri
 
C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
Farhan Ab Rahman
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
OdessaJS Conf
 

What's hot (20)

Solidity Security and Best Coding Practices
Solidity Security and Best Coding PracticesSolidity Security and Best Coding Practices
Solidity Security and Best Coding Practices
 
Blockchain and Smart Contracts
Blockchain and Smart ContractsBlockchain and Smart Contracts
Blockchain and Smart Contracts
 
Solidity Simple Tutorial EN
Solidity Simple Tutorial ENSolidity Simple Tutorial EN
Solidity Simple Tutorial EN
 
Blockchain Coding Dojo - BlockchainHub Graz
Blockchain Coding Dojo - BlockchainHub GrazBlockchain Coding Dojo - BlockchainHub Graz
Blockchain Coding Dojo - BlockchainHub Graz
 
Ripple
RippleRipple
Ripple
 
Smart Contract programming 101 with Solidity #PizzaHackathon
Smart Contract programming 101 with Solidity #PizzaHackathonSmart Contract programming 101 with Solidity #PizzaHackathon
Smart Contract programming 101 with Solidity #PizzaHackathon
 
Ethereum Contracts - Coinfest 2015
Ethereum Contracts - Coinfest 2015Ethereum Contracts - Coinfest 2015
Ethereum Contracts - Coinfest 2015
 
Solidity
SoliditySolidity
Solidity
 
Smart contract and Solidity
Smart contract and SoliditySmart contract and Solidity
Smart contract and Solidity
 
“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
 
ERC20 Token Contract
ERC20 Token ContractERC20 Token Contract
ERC20 Token Contract
 
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
 
Smart contracts in Solidity
Smart contracts in SoliditySmart contracts in Solidity
Smart contracts in 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 engineer
 
Oop1
Oop1Oop1
Oop1
 
(18.03.2009) Cumuy Invita - Iniciando el año conociendo nuevas tecnologías - ...
(18.03.2009) Cumuy Invita - Iniciando el año conociendo nuevas tecnologías - ...(18.03.2009) Cumuy Invita - Iniciando el año conociendo nuevas tecnologías - ...
(18.03.2009) Cumuy Invita - Iniciando el año conociendo nuevas tecnologías - ...
 
Cyber Security
Cyber SecurityCyber Security
Cyber Security
 
Ejemplos Programas Descompilados
Ejemplos Programas DescompiladosEjemplos Programas Descompilados
Ejemplos Programas Descompilados
 
C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
 

Similar to Hello world contract

Hands on with smart contracts
Hands on with smart contractsHands on with smart contracts
Hands on with smart contracts
Gene Leybzon
 
Security in the blockchain
Security in the blockchainSecurity in the blockchain
Security in the blockchain
Bellaj Badr
 
Ethereum
EthereumEthereum
Ethereum
Brian Yap
 
Ethereum Solidity Fundamentals
Ethereum Solidity FundamentalsEthereum Solidity Fundamentals
Ethereum Solidity Fundamentals
Eno Bassey
 
Ethereum
EthereumEthereum
Ethereum
V C
 
Smart contracts using web3.js
Smart contracts using web3.jsSmart contracts using web3.js
Smart contracts using web3.js
Felix Crisan
 
Blockchain, Ethereum and Business Applications
Blockchain, Ethereum and Business ApplicationsBlockchain, Ethereum and Business Applications
Blockchain, Ethereum and Business Applications
Matthias Zimmermann
 
Building Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart ContractBuilding Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart Contract
Vaideeswaran Sethuraman
 
Braga Blockchain - Ethereum Smart Contracts programming
Braga Blockchain - Ethereum Smart Contracts programmingBraga Blockchain - Ethereum Smart Contracts programming
Braga Blockchain - Ethereum Smart Contracts programming
Emanuel Mota
 
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Codemotion
 
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Codemotion
 
An Introduction to Upgradable Smart Contracts
An Introduction to Upgradable Smart ContractsAn Introduction to Upgradable Smart Contracts
An Introduction to Upgradable Smart Contracts
Mark Smalley
 
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
Shakacon
 
Algorand Smart Contracts
Algorand Smart ContractsAlgorand Smart Contracts
Algorand Smart Contracts
ssusercc3bf81
 
Ethereum Block Chain
Ethereum Block ChainEthereum Block Chain
Ethereum Block Chain
SanatPandoh
 
以太坊代幣付款委託 @ Open Source Developer Meetup #12
以太坊代幣付款委託 @ Open Source Developer Meetup #12以太坊代幣付款委託 @ Open Source Developer Meetup #12
以太坊代幣付款委託 @ Open Source Developer Meetup #12
Aludirk Wong
 
Blockchain for Developers
Blockchain for DevelopersBlockchain for Developers
Blockchain for Developers
Shimi Bandiel
 
Best practices to build secure smart contracts
Best practices to build secure smart contractsBest practices to build secure smart contracts
Best practices to build secure smart contracts
Gautam Anand
 
"Programming Smart Contracts on Ethereum" by Anatoly Ressin from AssistUnion ...
"Programming Smart Contracts on Ethereum" by Anatoly Ressin from AssistUnion ..."Programming Smart Contracts on Ethereum" by Anatoly Ressin from AssistUnion ...
"Programming Smart Contracts on Ethereum" by Anatoly Ressin from AssistUnion ...
Dace Barone
 
Blockchain Development
Blockchain DevelopmentBlockchain Development
Blockchain Development
preetikumara
 

Similar to Hello world contract (20)

Hands on with smart contracts
Hands on with smart contractsHands on with smart contracts
Hands on with smart contracts
 
Security in the blockchain
Security in the blockchainSecurity in the blockchain
Security in the blockchain
 
Ethereum
EthereumEthereum
Ethereum
 
Ethereum Solidity Fundamentals
Ethereum Solidity FundamentalsEthereum Solidity Fundamentals
Ethereum Solidity Fundamentals
 
Ethereum
EthereumEthereum
Ethereum
 
Smart contracts using web3.js
Smart contracts using web3.jsSmart contracts using web3.js
Smart contracts using web3.js
 
Blockchain, Ethereum and Business Applications
Blockchain, Ethereum and Business ApplicationsBlockchain, Ethereum and Business Applications
Blockchain, Ethereum and Business Applications
 
Building Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart ContractBuilding Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart Contract
 
Braga Blockchain - Ethereum Smart Contracts programming
Braga Blockchain - Ethereum Smart Contracts programmingBraga Blockchain - Ethereum Smart Contracts programming
Braga Blockchain - Ethereum Smart Contracts programming
 
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
 
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
 
An Introduction to Upgradable Smart Contracts
An Introduction to Upgradable Smart ContractsAn Introduction to Upgradable Smart Contracts
An Introduction to Upgradable Smart Contracts
 
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
 
Algorand Smart Contracts
Algorand Smart ContractsAlgorand Smart Contracts
Algorand Smart Contracts
 
Ethereum Block Chain
Ethereum Block ChainEthereum Block Chain
Ethereum Block Chain
 
以太坊代幣付款委託 @ Open Source Developer Meetup #12
以太坊代幣付款委託 @ Open Source Developer Meetup #12以太坊代幣付款委託 @ Open Source Developer Meetup #12
以太坊代幣付款委託 @ Open Source Developer Meetup #12
 
Blockchain for Developers
Blockchain for DevelopersBlockchain for Developers
Blockchain for Developers
 
Best practices to build secure smart contracts
Best practices to build secure smart contractsBest practices to build secure smart contracts
Best practices to build secure smart contracts
 
"Programming Smart Contracts on Ethereum" by Anatoly Ressin from AssistUnion ...
"Programming Smart Contracts on Ethereum" by Anatoly Ressin from AssistUnion ..."Programming Smart Contracts on Ethereum" by Anatoly Ressin from AssistUnion ...
"Programming Smart Contracts on Ethereum" by Anatoly Ressin from AssistUnion ...
 
Blockchain Development
Blockchain DevelopmentBlockchain Development
Blockchain Development
 

More from Gene Leybzon

Generative AI Application Development using LangChain and LangFlow
Generative AI Application Development using LangChain and LangFlowGenerative AI Application Development using LangChain and LangFlow
Generative AI Application Development using LangChain and LangFlow
Gene Leybzon
 
Chat GPTs
Chat GPTsChat GPTs
Chat GPTs
Gene Leybzon
 
Generative AI Use cases for Enterprise - Second Session
Generative AI Use cases for Enterprise - Second SessionGenerative AI Use cases for Enterprise - Second Session
Generative AI Use cases for Enterprise - Second Session
Gene Leybzon
 
Generative AI Use-cases for Enterprise - First Session
Generative AI Use-cases for Enterprise - First SessionGenerative AI Use-cases for Enterprise - First Session
Generative AI Use-cases for Enterprise - First Session
Gene Leybzon
 
Non-fungible tokens (nfts)
Non-fungible tokens (nfts)Non-fungible tokens (nfts)
Non-fungible tokens (nfts)
Gene Leybzon
 
Introduction to Solidity and Smart Contract Development (9).pptx
Introduction to Solidity and Smart Contract Development (9).pptxIntroduction to Solidity and Smart Contract Development (9).pptx
Introduction to Solidity and Smart Contract Development (9).pptx
Gene Leybzon
 
Ethereum in Enterprise.pptx
Ethereum in Enterprise.pptxEthereum in Enterprise.pptx
Ethereum in Enterprise.pptx
Gene Leybzon
 
ERC-4907 Rentable NFT Standard.pptx
ERC-4907 Rentable NFT Standard.pptxERC-4907 Rentable NFT Standard.pptx
ERC-4907 Rentable NFT Standard.pptx
Gene Leybzon
 
Onchain Decentralized Governance 2.pptx
Onchain Decentralized Governance 2.pptxOnchain Decentralized Governance 2.pptx
Onchain Decentralized Governance 2.pptx
Gene Leybzon
 
Onchain Decentralized Governance.pptx
Onchain Decentralized Governance.pptxOnchain Decentralized Governance.pptx
Onchain Decentralized Governance.pptx
Gene Leybzon
 
Web3 File Storage Options
Web3 File Storage OptionsWeb3 File Storage Options
Web3 File Storage Options
Gene Leybzon
 
Web3 Full Stack Development
Web3 Full Stack DevelopmentWeb3 Full Stack Development
Web3 Full Stack Development
Gene Leybzon
 
Instantly tradeable NFT contracts based on ERC-1155 standard
Instantly tradeable NFT contracts based on ERC-1155 standardInstantly tradeable NFT contracts based on ERC-1155 standard
Instantly tradeable NFT contracts based on ERC-1155 standard
Gene Leybzon
 
Non-fungible tokens. From smart contract code to marketplace
Non-fungible tokens. From smart contract code to marketplaceNon-fungible tokens. From smart contract code to marketplace
Non-fungible tokens. From smart contract code to marketplace
Gene Leybzon
 
The Art of non-fungible tokens
The Art of non-fungible tokensThe Art of non-fungible tokens
The Art of non-fungible tokens
Gene Leybzon
 
Graph protocol for accessing information about blockchains and d apps
Graph protocol for accessing information about blockchains and d appsGraph protocol for accessing information about blockchains and d apps
Graph protocol for accessing information about blockchains and d apps
Gene Leybzon
 
Substrate Framework
Substrate FrameworkSubstrate Framework
Substrate Framework
Gene Leybzon
 
Chainlink
ChainlinkChainlink
Chainlink
Gene Leybzon
 
OpenZeppelin + Remix + BNB smart chain
OpenZeppelin + Remix + BNB smart chainOpenZeppelin + Remix + BNB smart chain
OpenZeppelin + Remix + BNB smart chain
Gene Leybzon
 
Chainlink, Cosmos, Kusama, Polkadot: Approaches to the Internet of Blockchains
Chainlink, Cosmos, Kusama, Polkadot:   Approaches to the Internet of BlockchainsChainlink, Cosmos, Kusama, Polkadot:   Approaches to the Internet of Blockchains
Chainlink, Cosmos, Kusama, Polkadot: Approaches to the Internet of Blockchains
Gene Leybzon
 

More from Gene Leybzon (20)

Generative AI Application Development using LangChain and LangFlow
Generative AI Application Development using LangChain and LangFlowGenerative AI Application Development using LangChain and LangFlow
Generative AI Application Development using LangChain and LangFlow
 
Chat GPTs
Chat GPTsChat GPTs
Chat GPTs
 
Generative AI Use cases for Enterprise - Second Session
Generative AI Use cases for Enterprise - Second SessionGenerative AI Use cases for Enterprise - Second Session
Generative AI Use cases for Enterprise - Second Session
 
Generative AI Use-cases for Enterprise - First Session
Generative AI Use-cases for Enterprise - First SessionGenerative AI Use-cases for Enterprise - First Session
Generative AI Use-cases for Enterprise - First Session
 
Non-fungible tokens (nfts)
Non-fungible tokens (nfts)Non-fungible tokens (nfts)
Non-fungible tokens (nfts)
 
Introduction to Solidity and Smart Contract Development (9).pptx
Introduction to Solidity and Smart Contract Development (9).pptxIntroduction to Solidity and Smart Contract Development (9).pptx
Introduction to Solidity and Smart Contract Development (9).pptx
 
Ethereum in Enterprise.pptx
Ethereum in Enterprise.pptxEthereum in Enterprise.pptx
Ethereum in Enterprise.pptx
 
ERC-4907 Rentable NFT Standard.pptx
ERC-4907 Rentable NFT Standard.pptxERC-4907 Rentable NFT Standard.pptx
ERC-4907 Rentable NFT Standard.pptx
 
Onchain Decentralized Governance 2.pptx
Onchain Decentralized Governance 2.pptxOnchain Decentralized Governance 2.pptx
Onchain Decentralized Governance 2.pptx
 
Onchain Decentralized Governance.pptx
Onchain Decentralized Governance.pptxOnchain Decentralized Governance.pptx
Onchain Decentralized Governance.pptx
 
Web3 File Storage Options
Web3 File Storage OptionsWeb3 File Storage Options
Web3 File Storage Options
 
Web3 Full Stack Development
Web3 Full Stack DevelopmentWeb3 Full Stack Development
Web3 Full Stack Development
 
Instantly tradeable NFT contracts based on ERC-1155 standard
Instantly tradeable NFT contracts based on ERC-1155 standardInstantly tradeable NFT contracts based on ERC-1155 standard
Instantly tradeable NFT contracts based on ERC-1155 standard
 
Non-fungible tokens. From smart contract code to marketplace
Non-fungible tokens. From smart contract code to marketplaceNon-fungible tokens. From smart contract code to marketplace
Non-fungible tokens. From smart contract code to marketplace
 
The Art of non-fungible tokens
The Art of non-fungible tokensThe Art of non-fungible tokens
The Art of non-fungible tokens
 
Graph protocol for accessing information about blockchains and d apps
Graph protocol for accessing information about blockchains and d appsGraph protocol for accessing information about blockchains and d apps
Graph protocol for accessing information about blockchains and d apps
 
Substrate Framework
Substrate FrameworkSubstrate Framework
Substrate Framework
 
Chainlink
ChainlinkChainlink
Chainlink
 
OpenZeppelin + Remix + BNB smart chain
OpenZeppelin + Remix + BNB smart chainOpenZeppelin + Remix + BNB smart chain
OpenZeppelin + Remix + BNB smart chain
 
Chainlink, Cosmos, Kusama, Polkadot: Approaches to the Internet of Blockchains
Chainlink, Cosmos, Kusama, Polkadot:   Approaches to the Internet of BlockchainsChainlink, Cosmos, Kusama, Polkadot:   Approaches to the Internet of Blockchains
Chainlink, Cosmos, Kusama, Polkadot: Approaches to the Internet of Blockchains
 

Recently uploaded

快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
3a0sd7z3
 
Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!
Toptal Tech
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
Donato Onofri
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
3a0sd7z3
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
k4ncd0z
 
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalmanuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
wolfsoftcompanyco
 
[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024
hackersuli
 
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
fovkoyb
 
Gen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needsGen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needs
Laura Szabó
 
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
ysasp1
 
Design Thinking NETFLIX using all techniques.pptx
Design Thinking NETFLIX using all techniques.pptxDesign Thinking NETFLIX using all techniques.pptx
Design Thinking NETFLIX using all techniques.pptx
saathvikreddy2003
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
davidjhones387
 
办理毕业证(UPenn毕业证)宾夕法尼亚大学毕业证成绩单快速办理
办理毕业证(UPenn毕业证)宾夕法尼亚大学毕业证成绩单快速办理办理毕业证(UPenn毕业证)宾夕法尼亚大学毕业证成绩单快速办理
办理毕业证(UPenn毕业证)宾夕法尼亚大学毕业证成绩单快速办理
uehowe
 
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
bseovas
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
Paul Walk
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
rtunex8r
 
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
uehowe
 
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
xjq03c34
 
办理毕业证(NYU毕业证)纽约大学毕业证成绩单官方原版办理
办理毕业证(NYU毕业证)纽约大学毕业证成绩单官方原版办理办理毕业证(NYU毕业证)纽约大学毕业证成绩单官方原版办理
办理毕业证(NYU毕业证)纽约大学毕业证成绩单官方原版办理
uehowe
 

Recently uploaded (19)

快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
 
Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
 
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalmanuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
 
[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024
 
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
 
Gen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needsGen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needs
 
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
 
Design Thinking NETFLIX using all techniques.pptx
Design Thinking NETFLIX using all techniques.pptxDesign Thinking NETFLIX using all techniques.pptx
Design Thinking NETFLIX using all techniques.pptx
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
 
办理毕业证(UPenn毕业证)宾夕法尼亚大学毕业证成绩单快速办理
办理毕业证(UPenn毕业证)宾夕法尼亚大学毕业证成绩单快速办理办理毕业证(UPenn毕业证)宾夕法尼亚大学毕业证成绩单快速办理
办理毕业证(UPenn毕业证)宾夕法尼亚大学毕业证成绩单快速办理
 
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
 
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
 
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
 
办理毕业证(NYU毕业证)纽约大学毕业证成绩单官方原版办理
办理毕业证(NYU毕业证)纽约大学毕业证成绩单官方原版办理办理毕业证(NYU毕业证)纽约大学毕业证成绩单官方原版办理
办理毕业证(NYU毕业证)纽约大学毕业证成绩单官方原版办理
 

Hello world contract

  • 1. “HELLO WORLD” SMART CONTRACT Hands-on introduction to the world of Solidity and Smart contract programming on Ethereum
  • 2. PLAN FOR TODAY Blockchain introduction for Engineers Understand basis Etherium concepts Selenium Language Create your first contract Compile Test
  • 4. WHY BLOCKCHAIN IS A BIG DEAL “Bitcoin is a technological tour de force.” – Bill Gates ”I think the fact that within the bitcoin universe an algorithm replaces the function of the government …[that] is actually pretty cool.” - Al Gore “[Bitcoin] is a remarkable cryptographic achievement… The ability to create something which is not duplicable in the digital world has enormous value…Lot’s of people will build businesses on top of that.” - Eric Schmidt
  • 5. BLOCKCHAIN IS Ledger of facts Ledger of facts replicated across large number of computers Ledger of facts replicated across large number of computers connected as peer-to-peer network Ledger of facts replicated across large number of computers connected as peer-to-peer network that implements consensus algorithm that can securely identify sender and receiver of facts FACT S Monetary transactio n Content hash Signature Asset informatio n Ownership Agreemen t Contract
  • 6. IS IT JUST ANOTHER SHARED DATABASE?
  • 8. Blockchain is a source of truth
  • 14. Smart Contract Definition Smart contract are applications that run exactly as programmed without any possibility of downtime, censorship, fraud or third party interference.
  • 15. EXAMPLE OF A CONTRACT
  • 18. TWO TYPES OF ACCOUNTS Account StorageBalance Code <> Externally Owned Account StorageBalance Account StorageBalance Code <> Contract StorageBalance Code <>
  • 19. CONTRACTS Contracts are accounts that contain code Store the state • Example: keeps account balance Source of notifications (events) • Example: messaging service that forwards only messages when certain conditions are met Mapping - relationship between users • Example: mapping real- world financial contract to Etherium contract Act like a software library • Example: return calculated value based on message arguments
  • 20. CALLS AND MESSAGES Contract A Contract B Message Call • Source • Target • Data Payload • Ether • Gas • Return Data Externally owned account Message CallSend Transaction Call
  • 21. WHAT CONTRACT CAN DO? Read internal state contract ReadStateDemo { uint public state; function read() { console.log(“State: "+state); } } Modify internal State contract ModStateDemo { uint public state; function update() { state=state+1; } } Consume message contract ReadStateDemo { uint public state; function hi() { console.log(“Hello from: “ "+msg.sender + “ to “ + msg. receiver); } } Trigger execution of another contract contract CallDemo { function send(address receiver, uint amount) public { Sent(msg.sender, receiver, amount); } }
  • 23. REGISTRARS (ETHEREUM NAME SERVICE, ENS) 1. Send ether to an address in Metamask (soon: MEW, Mist, Bitfinex) 1. Use it inside your own contracts to resolve names of other contracts and addresses 2. Store contract ABIs for easy lookup using the ethereum-ens library 3. Address of a Swarm site Use Cases Registry Registar Resolver
  • 24. ETHER • Wei: 1 • Ada: 1000 • Fentoether: 1000 • Kwei: 1,000 • Mwei: 1,000,000 • Babbage: 1,000,000 • Pictoether: 1,000,000 • Shannon: 1,000,000,000 • Gwei: 1,000,000,000 • Nano: 1,000,000,000 • Szabo: 1,000,000,000,000 • Micro: 1,000,000,000,000 • Microether: 1,000,000,000,000 • Finney: 1,000,000,000,000,000 • Milli: 1,000,000,000,000,000 • Milliether: 1,000,000,000,000,000 • Ether: 1,000,000,000,000,000,000 Wei = 10-18 Ether
  • 25. GAS step 1 Default amount of gas to pay for an execution cycle stop 0 Nothing paid for the STOP operation suicide 0 Nothing paid for the SUICIDE operation sha3 20 Paid for a SHA3 operation sload 30 Paid for a SLOAD operation sstore 100 Paid for a normal SSTORE operation (doubled or waived sometimes) balance 20 Paid for a BALANCE operation create 100 Paid for a CREATE operation call 20 Paid for a CALL operation memory 1 Paid for every additional word when expanding memory txdata 5 Paid for every byte of data or code for a transaction Example: 300 CPU cycles = 300 gas units = 0.000006 ETH = $0.00553 (as of 2/20/2018) Cost of Gas as in 2018
  • 28. ELEMENTARY DATA TYPES Data Type Example uint<M> , M=1,2,4, …, 256 int<M>, uint, int Unsigned/signed integer uint256 counter = 1; address 160-bit value that does not allow any arithmetic operations. It is suitable for storing addresses of contracts or keypairs belonging to external persons address owner = msg.sender; bool Same as uint8 but values are 0 or 1 Bool b = 0; fixed<M>x<N> ufixed<M>x<N> Signed fixed-point decimal number of M bits fixed128x19 f = 1.1; bytes<M>, M=1..32 Binary of M bytes bytes32 n=123; function Same as bytes24 Function f;
  • 29. ARRAYS Data Type Example <type>[M] fixed-length array of fixed- length type byte[100] <type>[] variable-length array of fixed- length type byte[] bytes dynamic sized byte sequence bytes ab; string dynamic sized Unicode string String s = “String”; fixed<M>x<N> ufixed<M>x<N> Signed fixed-point decimal number of M bits fixed128x19 f = 1.1;
  • 30. FUNCTIONS Functio ns Consta nt Transactio nal Function Visibility External Can be called via transactions Public Can be called via messages or locally Internal Only locally called or from derived contracts Private Locally called pragma solidity^0.4.12; contract Test { function test(uint[20] a) public returns (uint){ return a[10]*2; } function test2(uint[20] a) external returns (uint){ return a[10]*2; } } }
  • 32. HELLO WORLD CONTRACT (SOLIDITY CODE) pragma solidity ^0.4.24; contract Hello { constructor() public { // constructor } function sayHello() public pure returns (string) { return 'Hello World!'; } }
  • 36. SECOND CONTRACT (COUNTING) pragma solidity ^0.4.24; contract Count { uint public value = 0; function plus() public returns (uint) { value++; return value; } }
  • 37. More Contracts to Work On https://github.com/leybzon/solidity- baby-steps/tree/master/contracts
  • 39. ERC223 TOKEN ERC223 is backwards compatible with ERC20 merges the token transfer function among wallets and contracts into one single function ‘transfer()’ does not allow token to be transferred to a contract that does not allow token to be withdrawn Improvements with ERC223 • Eliminates the problem of lost tokens which happens during the transfer of ERC20 tokens to a contract (when people mistakenly use the instructions for sending tokens to a wallet). ERC223 allows users to send their tokens to either wallet or contract with the same function transfer, thereby eliminating the potential for confusion and lost tokens. • Allows developers to handle incoming token transactions, and reject non-supported tokens (not possible with ERC20) • Energy savings. The transfer of ERC223 tokens to a contract is a one step process rather than 2 step process (for ERC20), and this means 2 times less gas and no extra blockchain bloating.
  • 40. ERC223 TOKEN INTERFACE contract ERC223 { uint public totalSupply; function balanceOf(address who) public view returns (uint); function name() public view returns (string _name); function symbol() public view returns (string _symbol); function decimals() public view returns (uint8 _decimals); function totalSupply() public view returns (uint256 _supply); function transfer(address to, uint value) public returns (bool ok); function transfer(address to, uint value, bytes data) public returns (bool ok); function transfer(address to, uint value, bytes data, string custom_fallback) public returns (bool ok); event Transfer(address indexed from, address indexed to, uint value, bytes indexed data); }
  • 41. ERC721 ▪People love collecting ▪Allow smart contracts to operate as tradable tokens ▪Each ERC721 is unique (non-fungible) ▪Support “ownership” functions ▪Each token is referenced by unique id ▪Tokens can have metadata (attributes)
  • 42. ERC721 contract ERC721 { event Transfer(address indexed _from, address indexed _to, uint256 _tokenId); event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId); function balanceOf(address _owner) public view returns (uint256 _balance); function ownerOf(uint256 _tokenId) public view returns (address _owner); function transfer(address _to, uint256 _tokenId) public; function approve(address _to, uint256 _tokenId) public; function takeOwnership(uint256 _tokenId) public; }
  • 43. STAY IN TOUCH Gene Leybzon https://www.linkedin.com/in/leybzon/ https://www.meetup.com/Blockchain- Applications-and-Smart-Contracts/ https://www.meetup.com/members/9074420/ https://www.leybzon.com
  • 44. NEXT STEPS http://solidity.readthedocs.ioLanguage • Learn Solidity Ideas People • Meetups • Conferences