SlideShare a Scribd company logo
t
Introduction to
Blockchain &
Smart Contracts
April 30, 2018Sandip Pandey
1
Create your own Cryptocurrency Token
- Blockchain Enthusiast
- Blockchain Research Engineer
Blockchain Labs, TU Delft
- EIT Digital Alumni (2016)
https://github.com/xoriole
https://www.linkedin.com/in/sandippandey/
About Me
2
1500+ more
Blockchain is a Solution looking for a Problem!
“Create your own cryptocurrency in an hour” - Sandip Pandey
Source: Bitcoin: A Peer-to-Peer Electronic Cash System, S. Nakamoto
        
        
      
“Create your own cryptocurrency in an hour” - Sandip Pandey
→ SHOW US SOME PROOF
Proof of work
Proof of burn
Proof of activity
Proof of stake
Proof of capacity
Proof of elapsed time Proof of ...
- First digital decentralized cryptocurrency
- Founder: Satoshi Nakamoto
- Proof of work consensus
- Pseudonymous
Eg. 1CF6yUN61c4zmE2wTibhPhh53sJ5s4VLsa
Bitcoin Scripts are limited in capability & Restrictive
Input Script
Output Script
A decentralized platform that runs smart contracts
Smart Contract
A collection of code (functions) and data (state) that resides at a specific
address on the blockchain
- Digital Token
- Trustless Crowdsale
- Democratic Autonomous Organizations
- so on …
One step further towards a Programmable Economy
“Create your own cryptocurrency in an hour” - Sandip Pandey
Trade
Finance
Supply
Chain &
Logistics
Health &
Medicine
Self
Sovereign
Identity
...Mortgages
Energy &
Smart Grid
Securities &
Insurance
❏ Multiple interacting entities
❏ Data represents some form of value or asset
❏ Data is shared among the entities
❏ All updates on data need to be logged
❏ Entities need to trust the shared state of data & all updates made on them
❏ CONSISTENCY, VALIDITY and IMMUTABILITY of the data is important
❏ Incremental data dependency
❏ High operational costs (intermediary)
Immutability isn’t always a good thing
- Data written on blockchain cannot be changed or deleted
- No correction of mistakes (Hard Fork?)
- Legal issues: EU - Right to be forgotten
- Think before writing privacy sensitive information on blockchain
Performance Issues
- Transaction delay & Confirmation time
- Transaction throughput (tx/second)
“Create your own cryptocurrency in an hour” - Sandip Pandey
User Account
- Address
- Balance
Smart Contract
- Address
- Balance
- Code
- State
Source: http://www.gjermundbjaanes.com/img/posts/smart_contract_infographic.png
- Transfer of Value
- Smart Contract creation
- Call contract
- Transfer of Value
- Smart Contract creation
- Call contract
{
‘to’: ‘0x990FcbF55D6eD9493c62e11da388A4D89d857200’,
‘value’: 0.500
‘data’: ‘0x’
}
- Transfer of Value
- Smart Contract creation
- Call contract
{
‘to’: ‘’,
‘value’: 0.0
‘data’: ‘0x60806040526040805190810160405280601a….’
}
- Transfer of Value
- Smart Contract creation
- Call contract
{
‘to’: ‘0x990FcbF55D6eD9493c62e11da388A4D89d857200’, // contract
‘value’: 0.0
‘data’: ‘0xa9059cbb000000000000000000000000990fcbf55d...c8’
}
Source: http://www.gjermundbjaanes.com/img/posts/calling_a_smart_contract_infographic.png
“Create your own cryptocurrency in an hour” - Sandip Pandey
❏ Ethereum wallet
❏ Some ethers
❏ An IDE to write and deploy smart contract
❏ Many options - Ethereum wallet (official)/Mist, Metamask, MyEtherWallet, ...
❏ We use Metamask chrome plugin ( https://metamask.io )
Create an account with a
good password
Copy the seed words and
keep it safe.
Your wallet account home
screen
Copy your address.
For eg. 0xC594...277
❏ Ether Network Chains
❏ Main network (ETH)
❏ Test networks
❏ Ropsten
❏ Kovan
❏ Rinkeby << We’ll use this one
❏ Others
❏ Expanse (EXP)
❏ Ubiq (UBQ)
❏ ...
❏ Rinkeby Faucet
https://faucet.rinkeby.io/
❏ Options
❏ Ethereum Wallet/Mist
❏ Remix IDE
https://remix.ethereum.org
❏ ...
“Create your own cryptocurrency in an hour” - Sandip Pandey
Some information about token
- Name,
- Symbol,
- Number of decimals,
- total supply
Some information about token
- Name,
- Symbol,
- Number of decimals,
- total supply
Some information of account and account balance
- Which address has how many tokens?
Some information about token
- Name,
- Symbol,
- Number of decimals,
- total supply
Some information of account and account balance
- Which address has how many tokens?
Movement of tokens
- Transfer of tokens from one account to another
pragma solidity ^0.4.12;
contract MyFirstToken {
string public name = "MyFirstToken";
string public symbol = "MFT";
uint8 public decimals = 2;
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
/**Constructor. Initializes contract with some initial supply tokens.*/
function MyFirstToken( uint256 initialSupply) public {
totalSupply = initialSupply * 10 ** uint256(decimals);
balanceOf[msg.sender] = totalSupply;
}
// transfer function in next slide
}
[ http://bit.ly/my-first-token ]
pragma solidity ^0.4.12;
contract MyFirstToken {
/** Transfer tokens.*/
function transfer(address _to, uint _value) public {
// Prevent transfer to 0x0 address.
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[msg.sender] >= _value);
// Check for overflows
require(balanceOf[_to] + _value >= balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[msg.sender] + balanceOf[_to];
// Subtract from the sender
balanceOf[msg.sender] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
//Make sure math is right. Assertions should never fail
assert(balanceOf[msg.sender] + balanceOf[_to] == previousBalances);
}
}
[ http://bit.ly/my-first-token ]
Requirements
- Basic Token +
- Foundation creates the token
- Token should be transferable
- Only alumni can send/receive tokens
- Foundation can register alumni in blockchain
http://bit.ly/alumni-credits
[ http://bit.ly/alumni-credits ]
pragma solidity ^0.4.12;
contract AlumniCredits {
string public name = "AlumniCredits";
string public symbol = "EITDAC";
uint8 public decimals = 2;
uint256 public totalSupply;
// Foundation address
address public foundation;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
/**Constructor. Initializes contract with some initial supply tokens.*/
function AlumniCredits( uint256 initialSupply) public {
foundation = msg.sender; // contract creator is the foundation
totalSupply = initialSupply * 10 ** uint256(decimals);
balanceOf[foundation] = totalSupply;
registered[foundation] = true;
}
}
[ http://bit.ly/alumni-credits ]
pragma solidity ^0.4.12;
contract AlumniCredits {
// All registered/valid alumni addresses approved by the foundation
mapping (address => bool) registeredAlumni;
/** Transfer tokens.*/
function transfer(address _to, uint _value) public {
//Make sure receiver is also alumni
require(registeredAlumni[_alumni] == true);
// Rest is same as basic token…
}
// Register an alumni address.Can be done by foundation only.
function registerAlumni(address _address) public onlyFoundation {
registeredAlumni[_address] = true;
}
//Check if an address belongs to a registered alumni
function isRegistered(address _address) public view returns (bool registered){
return registeredAlumni[_address] == true;
}
}
[ http://bit.ly/alumni-credits ]
“Create your own cryptocurrency in an hour” - Sandip Pandey
// Abstract contract for the full ERC 20 Token standard
// https://github.com/ethereum/EIPs/issues/20
pragma solidity ^0.4.8;
contract Token {
string public name;
string public symbol;
uint8 public decimals = 18;
uint256 public totalSupply;
function balanceOf(address _owner) constant returns (uint256 balance);
function transfer(address _to, uint256 _value) returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
function approve(address _spender, uint256 _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
- Determined at the time contract is created
- Derived from creator address and “nonce”
- A Contract cannot be re-deployed at the same contract address
- Determined at the time contract is created
- Derived from creator address and “nonce”
- A Contract cannot be re-deployed at the same contract address
BUG IN THE CONTRACT
HOW TO FIX THEM?
1. Separate Data and Logic
Eg. prepare separate contracts for data storage and application logic
2. Maintain a versioning of contracts (sort of)
3. Delegator/Proxy Contract
Delegator delegates all the calls to latest implementation of the contract
Identity & Access Control
- Who has what level of control on the contract functions and data?
- Access & privilege control
Data Privacy
- Data encryption, Encryption Algorithms,
- Digital Signatures etc.
Future is decentralized!

More Related Content

What's hot (20)

PPTX
Solidity Simple Tutorial EN
Nicholas Lin
 
PPTX
Dex and Uniswap
Gene Leybzon
 
PPTX
Solidity
gavofyork
 
PPTX
Solidity Security and Best Coding Practices
Gene Leybzon
 
PPTX
Hands on with smart contracts
Gene Leybzon
 
PDF
Ethereum Contracts - Coinfest 2015
Rhea Myers
 
PPTX
From CRUD to messages: a true story
Alessandro Melchiori
 
PPTX
Hands on with Smart Contracts session #3
Gene Leybzon
 
PDF
Spring Transaction
Jannarong Wadthong
 
PDF
Declaring friend function with inline code
Rajeev Sharan
 
PPTX
Oracles
Gene Leybzon
 
PDF
Rajeev oops 2nd march
Rajeev Sharan
 
PDF
Logging in code
Jannarong Wadthong
 
PDF
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
병완 임
 
PPTX
Migrating our micro services from Java to Kotlin 2.0
Björn Wendland
 
PDF
Smart contracts in Solidity
Felix Crisan
 
PDF
Taming Distribution: Formal Protocols for Akka Typed
Roland Kuhn
 
PDF
Braga Blockchain - Ethereum Smart Contracts programming
Emanuel Mota
 
PPTX
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
Alfonso Peletier
 
PDF
How to be a smart contract engineer
Oded Noam
 
Solidity Simple Tutorial EN
Nicholas Lin
 
Dex and Uniswap
Gene Leybzon
 
Solidity
gavofyork
 
Solidity Security and Best Coding Practices
Gene Leybzon
 
Hands on with smart contracts
Gene Leybzon
 
Ethereum Contracts - Coinfest 2015
Rhea Myers
 
From CRUD to messages: a true story
Alessandro Melchiori
 
Hands on with Smart Contracts session #3
Gene Leybzon
 
Spring Transaction
Jannarong Wadthong
 
Declaring friend function with inline code
Rajeev Sharan
 
Oracles
Gene Leybzon
 
Rajeev oops 2nd march
Rajeev Sharan
 
Logging in code
Jannarong Wadthong
 
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
병완 임
 
Migrating our micro services from Java to Kotlin 2.0
Björn Wendland
 
Smart contracts in Solidity
Felix Crisan
 
Taming Distribution: Formal Protocols for Akka Typed
Roland Kuhn
 
Braga Blockchain - Ethereum Smart Contracts programming
Emanuel Mota
 
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
Alfonso Peletier
 
How to be a smart contract engineer
Oded Noam
 

Similar to “Create your own cryptocurrency in an hour” - Sandip Pandey (20)

PPTX
Smart Contract programming 101 with Solidity #PizzaHackathon
Sittiphol Phanvilai
 
ODP
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
Codemotion
 
PDF
Blockchain and smart contracts, what they are and why you should really care ...
maeste
 
PPTX
Introduction_to_Blockchain_&_Ethereum.pptx
WijdenBenothmen1
 
PDF
Part 4: Understanding the working of Smart Contracts
Jyoti Yadav
 
PDF
Blockchain School 2019 - Security of Smart Contracts.pdf
Davide Carboni
 
PPTX
Introduction to Solidity and Smart Contract Development (9).pptx
Gene Leybzon
 
PPTX
Ethereum Block Chain
SanatPandoh
 
PDF
Developing Non-Fungible Tokens using Ethereum Smart Contract
NUS-ISS
 
DOCX
Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp
 
PDF
Smart contract and Solidity
겨울 정
 
PPTX
Kriptovaluták, hashbányászat és okoscicák
hackersuli
 
PDF
An Introduction to Upgradable Smart Contracts
Mark Smalley
 
PPTX
lecture7 blockchain ethereum mechanics 101
HariPurnama5
 
PPTX
Blockchain for Developers
Shimi Bandiel
 
PPTX
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Tomoaki Sato
 
PPTX
The Ethereum Blockchain - Introduction to Smart Contracts and Decentralized A...
I.I.S. G. Vallauri - Fossano
 
PDF
Introduction to Ethereum Smart Contracts
ArcBlock
 
PPTX
Ethereum
V C
 
PDF
solutions.hamburg | web3 // smart contracts // ethereum
Maximilian Reichel
 
Smart Contract programming 101 with Solidity #PizzaHackathon
Sittiphol Phanvilai
 
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
Codemotion
 
Blockchain and smart contracts, what they are and why you should really care ...
maeste
 
Introduction_to_Blockchain_&_Ethereum.pptx
WijdenBenothmen1
 
Part 4: Understanding the working of Smart Contracts
Jyoti Yadav
 
Blockchain School 2019 - Security of Smart Contracts.pdf
Davide Carboni
 
Introduction to Solidity and Smart Contract Development (9).pptx
Gene Leybzon
 
Ethereum Block Chain
SanatPandoh
 
Developing Non-Fungible Tokens using Ethereum Smart Contract
NUS-ISS
 
Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp
 
Smart contract and Solidity
겨울 정
 
Kriptovaluták, hashbányászat és okoscicák
hackersuli
 
An Introduction to Upgradable Smart Contracts
Mark Smalley
 
lecture7 blockchain ethereum mechanics 101
HariPurnama5
 
Blockchain for Developers
Shimi Bandiel
 
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Tomoaki Sato
 
The Ethereum Blockchain - Introduction to Smart Contracts and Decentralized A...
I.I.S. G. Vallauri - Fossano
 
Introduction to Ethereum Smart Contracts
ArcBlock
 
Ethereum
V C
 
solutions.hamburg | web3 // smart contracts // ethereum
Maximilian Reichel
 
Ad

More from EIT Digital Alumni (12)

PDF
EIT Digital Alumni Foundation - About us
EIT Digital Alumni
 
PDF
The EIT Digital Alumni Foundation
EIT Digital Alumni
 
PDF
"CERN: An Innovation Hub" - Ranveig Strøm
EIT Digital Alumni
 
PDF
"EIT Digital Alumni: State of Play" - Francesco Bonadiman
EIT Digital Alumni
 
PDF
“Blockchain & Energy: hype or solution?” - Simone Accornero
EIT Digital Alumni
 
PPTX
“Internet of Things: Theory and Practice” - Roman Chirikov
EIT Digital Alumni
 
PDF
“Earthquakes aren’t the only thing shaking up Santiago” - Dora Palfi
EIT Digital Alumni
 
PDF
“The power of a movement” - Jeroen Van Lent
EIT Digital Alumni
 
PDF
“How can the blockchain make electronic voting more secure?” - István András ...
EIT Digital Alumni
 
PDF
“Thread - A New Wireless Networking Protocol for Internet of Things” - Ankith...
EIT Digital Alumni
 
PDF

“Hands-on: Build a Low-Power IoT Prototype” - Hylke Visser
EIT Digital Alumni
 
PDF

“Towards Machine Intelligence” - Daniyal Shahrokhian
EIT Digital Alumni
 
EIT Digital Alumni Foundation - About us
EIT Digital Alumni
 
The EIT Digital Alumni Foundation
EIT Digital Alumni
 
"CERN: An Innovation Hub" - Ranveig Strøm
EIT Digital Alumni
 
"EIT Digital Alumni: State of Play" - Francesco Bonadiman
EIT Digital Alumni
 
“Blockchain & Energy: hype or solution?” - Simone Accornero
EIT Digital Alumni
 
“Internet of Things: Theory and Practice” - Roman Chirikov
EIT Digital Alumni
 
“Earthquakes aren’t the only thing shaking up Santiago” - Dora Palfi
EIT Digital Alumni
 
“The power of a movement” - Jeroen Van Lent
EIT Digital Alumni
 
“How can the blockchain make electronic voting more secure?” - István András ...
EIT Digital Alumni
 
“Thread - A New Wireless Networking Protocol for Internet of Things” - Ankith...
EIT Digital Alumni
 

“Hands-on: Build a Low-Power IoT Prototype” - Hylke Visser
EIT Digital Alumni
 

“Towards Machine Intelligence” - Daniyal Shahrokhian
EIT Digital Alumni
 
Ad

Recently uploaded (20)

PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 

“Create your own cryptocurrency in an hour” - Sandip Pandey

  • 1. t Introduction to Blockchain & Smart Contracts April 30, 2018Sandip Pandey 1 Create your own Cryptocurrency Token
  • 2. - Blockchain Enthusiast - Blockchain Research Engineer Blockchain Labs, TU Delft - EIT Digital Alumni (2016) https://github.com/xoriole https://www.linkedin.com/in/sandippandey/ About Me 2
  • 4. Blockchain is a Solution looking for a Problem!
  • 6. Source: Bitcoin: A Peer-to-Peer Electronic Cash System, S. Nakamoto
  • 9. → SHOW US SOME PROOF Proof of work Proof of burn Proof of activity Proof of stake Proof of capacity Proof of elapsed time Proof of ...
  • 10. - First digital decentralized cryptocurrency - Founder: Satoshi Nakamoto - Proof of work consensus - Pseudonymous Eg. 1CF6yUN61c4zmE2wTibhPhh53sJ5s4VLsa
  • 11. Bitcoin Scripts are limited in capability & Restrictive Input Script Output Script
  • 12. A decentralized platform that runs smart contracts Smart Contract A collection of code (functions) and data (state) that resides at a specific address on the blockchain - Digital Token - Trustless Crowdsale - Democratic Autonomous Organizations - so on … One step further towards a Programmable Economy
  • 15. ❏ Multiple interacting entities ❏ Data represents some form of value or asset ❏ Data is shared among the entities ❏ All updates on data need to be logged ❏ Entities need to trust the shared state of data & all updates made on them ❏ CONSISTENCY, VALIDITY and IMMUTABILITY of the data is important ❏ Incremental data dependency ❏ High operational costs (intermediary)
  • 16. Immutability isn’t always a good thing - Data written on blockchain cannot be changed or deleted - No correction of mistakes (Hard Fork?) - Legal issues: EU - Right to be forgotten - Think before writing privacy sensitive information on blockchain Performance Issues - Transaction delay & Confirmation time - Transaction throughput (tx/second)
  • 18. User Account - Address - Balance Smart Contract - Address - Balance - Code - State Source: http://www.gjermundbjaanes.com/img/posts/smart_contract_infographic.png
  • 19. - Transfer of Value - Smart Contract creation - Call contract
  • 20. - Transfer of Value - Smart Contract creation - Call contract { ‘to’: ‘0x990FcbF55D6eD9493c62e11da388A4D89d857200’, ‘value’: 0.500 ‘data’: ‘0x’ }
  • 21. - Transfer of Value - Smart Contract creation - Call contract { ‘to’: ‘’, ‘value’: 0.0 ‘data’: ‘0x60806040526040805190810160405280601a….’ }
  • 22. - Transfer of Value - Smart Contract creation - Call contract { ‘to’: ‘0x990FcbF55D6eD9493c62e11da388A4D89d857200’, // contract ‘value’: 0.0 ‘data’: ‘0xa9059cbb000000000000000000000000990fcbf55d...c8’ }
  • 25. ❏ Ethereum wallet ❏ Some ethers ❏ An IDE to write and deploy smart contract
  • 26. ❏ Many options - Ethereum wallet (official)/Mist, Metamask, MyEtherWallet, ... ❏ We use Metamask chrome plugin ( https://metamask.io )
  • 27. Create an account with a good password Copy the seed words and keep it safe. Your wallet account home screen Copy your address. For eg. 0xC594...277
  • 28. ❏ Ether Network Chains ❏ Main network (ETH) ❏ Test networks ❏ Ropsten ❏ Kovan ❏ Rinkeby << We’ll use this one ❏ Others ❏ Expanse (EXP) ❏ Ubiq (UBQ) ❏ ...
  • 30. ❏ Options ❏ Ethereum Wallet/Mist ❏ Remix IDE https://remix.ethereum.org ❏ ...
  • 32. Some information about token - Name, - Symbol, - Number of decimals, - total supply
  • 33. Some information about token - Name, - Symbol, - Number of decimals, - total supply Some information of account and account balance - Which address has how many tokens?
  • 34. Some information about token - Name, - Symbol, - Number of decimals, - total supply Some information of account and account balance - Which address has how many tokens? Movement of tokens - Transfer of tokens from one account to another
  • 35. pragma solidity ^0.4.12; contract MyFirstToken { string public name = "MyFirstToken"; string public symbol = "MFT"; uint8 public decimals = 2; uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; /**Constructor. Initializes contract with some initial supply tokens.*/ function MyFirstToken( uint256 initialSupply) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; } // transfer function in next slide } [ http://bit.ly/my-first-token ]
  • 36. pragma solidity ^0.4.12; contract MyFirstToken { /** Transfer tokens.*/ function transfer(address _to, uint _value) public { // Prevent transfer to 0x0 address. require(_to != 0x0); // Check if the sender has enough require(balanceOf[msg.sender] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[msg.sender] + balanceOf[_to]; // Subtract from the sender balanceOf[msg.sender] -= _value; // Add the same to the recipient balanceOf[_to] += _value; //Make sure math is right. Assertions should never fail assert(balanceOf[msg.sender] + balanceOf[_to] == previousBalances); } } [ http://bit.ly/my-first-token ]
  • 37. Requirements - Basic Token + - Foundation creates the token - Token should be transferable - Only alumni can send/receive tokens - Foundation can register alumni in blockchain http://bit.ly/alumni-credits [ http://bit.ly/alumni-credits ]
  • 38. pragma solidity ^0.4.12; contract AlumniCredits { string public name = "AlumniCredits"; string public symbol = "EITDAC"; uint8 public decimals = 2; uint256 public totalSupply; // Foundation address address public foundation; // This creates an array with all balances mapping (address => uint256) public balanceOf; /**Constructor. Initializes contract with some initial supply tokens.*/ function AlumniCredits( uint256 initialSupply) public { foundation = msg.sender; // contract creator is the foundation totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[foundation] = totalSupply; registered[foundation] = true; } } [ http://bit.ly/alumni-credits ]
  • 39. pragma solidity ^0.4.12; contract AlumniCredits { // All registered/valid alumni addresses approved by the foundation mapping (address => bool) registeredAlumni; /** Transfer tokens.*/ function transfer(address _to, uint _value) public { //Make sure receiver is also alumni require(registeredAlumni[_alumni] == true); // Rest is same as basic token… } // Register an alumni address.Can be done by foundation only. function registerAlumni(address _address) public onlyFoundation { registeredAlumni[_address] = true; } //Check if an address belongs to a registered alumni function isRegistered(address _address) public view returns (bool registered){ return registeredAlumni[_address] == true; } } [ http://bit.ly/alumni-credits ]
  • 41. // Abstract contract for the full ERC 20 Token standard // https://github.com/ethereum/EIPs/issues/20 pragma solidity ^0.4.8; contract Token { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; function balanceOf(address _owner) constant returns (uint256 balance); function transfer(address _to, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); function allowance(address _owner, address _spender) constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
  • 42. - Determined at the time contract is created - Derived from creator address and “nonce” - A Contract cannot be re-deployed at the same contract address
  • 43. - Determined at the time contract is created - Derived from creator address and “nonce” - A Contract cannot be re-deployed at the same contract address BUG IN THE CONTRACT HOW TO FIX THEM?
  • 44. 1. Separate Data and Logic Eg. prepare separate contracts for data storage and application logic 2. Maintain a versioning of contracts (sort of) 3. Delegator/Proxy Contract Delegator delegates all the calls to latest implementation of the contract
  • 45. Identity & Access Control - Who has what level of control on the contract functions and data? - Access & privilege control Data Privacy - Data encryption, Encryption Algorithms, - Digital Signatures etc.