SlideShare une entreprise Scribd logo
1  sur  3
Télécharger pour lire hors ligne
Adder
pragma solidity ^0.4.2;
contract adder{
string name;
function setName(string _name) public {
name = _name;
}
function getName() constant returns (string){
return name;
}
function add(int a, int b){
return a+b;
}
}
GreeterSample
pragma solidity ^0.4.2;
contract greeter{
string greeting;
constructor(string _greeting) public{
greeting = _greeting;
}
function greet() constant public returns (string){
return greeting;
}
function setGreeting(string _greeting) public{
greeting = _greeting;
}
function greet2() constant public returns (string){
return "ethereum sample";
}
}
AuditLogSample
pragma solidity ^​0.4.2​;
contract auditlog{
string uid;
string audit;
string date;
function​ ​auditlog​(​string _uid, string _audit, string _date​){
uid= _uid;
audit= _audit;
date= _date;
}
function​ ​getUid​() ​constant​ ​returns​ (​string​){
return​ uid;
}
function​ ​getAudit​() ​constant​ ​returns​ (​string​){
return​ audit;
}
function​ ​getDate​() ​constant​ ​returns​ (​string​){
return​ date;
}
}
VotingSample
pragma solidity ^​0.4.18​;
contract Voting {
mapping (​bytes32​ => uint8) public votesReceived;
bytes32[] public candidateList;
​function​ ​Voting​(​bytes32[] candidateNames​) ​public​ {
candidateList = candidateNames;
}
function​ ​totalVotesFor​(​bytes32 candidate​) ​view​ ​public​ ​returns​ (​uint8​) {
​require​(validCandidate(candidate)); ​return​ votesReceived[candidate];
}
​function​ ​voteForCandidate​(​bytes32 candidate​) ​public​ {
​require​(validCandidate(candidate)); votesReceived[candidate] += ​1​;
}
​function​ ​validCandidate​(​bytes32 candidate​) ​view​ ​public​ ​returns​ (​bool​) {
​for​(uint i = ​0​; i < candidateList.length; i++) {
​if​ (candidateList[i] == candidate) {
​return​ ​true​;
}
}
return​ ​false​;
}
}
FeverContract
pragma solidity ^​0.4.17​;
contract FeverContract {
uint8 temperature;
​function​ ​FeverContract​(){
temperature = ​98​;
}
​function​ ​getTemperature​() ​public​ ​constant​ ​returns​ (​uint8​) {
​return​ temperature;
}
​function​ ​hasFever​() ​public​ ​constant​ ​returns​ (​bool​) {
​return​ temperature > ​100​;
}
​function​ ​increaseTemp​() ​public​ ​returns​ (​uint8​) {
​if​ (temperature > ​110​) revert();
temperature += ​1​;
​return​ temperature;
}
​function​ ​decreaseTemp​() ​public​ ​returns​ (​uint8​) {
​if​ (temperature < ​95​) revert();
temperature -= ​1​;
​return​ temperature;
}
}

Contenu connexe

Tendances

Async JavaScript in ES7
Async JavaScript in ES7Async JavaScript in ES7
Async JavaScript in ES7Mike North
 
The Ring programming language version 1.9 book - Part 77 of 210
The Ring programming language version 1.9 book - Part 77 of 210The Ring programming language version 1.9 book - Part 77 of 210
The Ring programming language version 1.9 book - Part 77 of 210Mahmoud Samir Fayed
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejsLearningTech
 
Data structures cs301 power point slides lecture 03
Data structures   cs301 power point slides lecture 03Data structures   cs301 power point slides lecture 03
Data structures cs301 power point slides lecture 03Nasir Mehmood
 
The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189Mahmoud Samir Fayed
 
Project_Euler_No_104_Pandigital_Fibonacci_ends
Project_Euler_No_104_Pandigital_Fibonacci_endsProject_Euler_No_104_Pandigital_Fibonacci_ends
Project_Euler_No_104_Pandigital_Fibonacci_ends? ?
 
Lec21-CS110 Computational Engineering
Lec21-CS110 Computational EngineeringLec21-CS110 Computational Engineering
Lec21-CS110 Computational EngineeringSri Harsha Pamu
 
The Ring programming language version 1.2 book - Part 42 of 84
The Ring programming language version 1.2 book - Part 42 of 84The Ring programming language version 1.2 book - Part 42 of 84
The Ring programming language version 1.2 book - Part 42 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 41 of 184
The Ring programming language version 1.5.3 book - Part 41 of 184The Ring programming language version 1.5.3 book - Part 41 of 184
The Ring programming language version 1.5.3 book - Part 41 of 184Mahmoud Samir Fayed
 

Tendances (19)

Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Async JavaScript in ES7
Async JavaScript in ES7Async JavaScript in ES7
Async JavaScript in ES7
 
Sortings
SortingsSortings
Sortings
 
Java script
Java scriptJava script
Java script
 
The Ring programming language version 1.9 book - Part 77 of 210
The Ring programming language version 1.9 book - Part 77 of 210The Ring programming language version 1.9 book - Part 77 of 210
The Ring programming language version 1.9 book - Part 77 of 210
 
C programs
C programsC programs
C programs
 
C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejs
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
Data structures cs301 power point slides lecture 03
Data structures   cs301 power point slides lecture 03Data structures   cs301 power point slides lecture 03
Data structures cs301 power point slides lecture 03
 
Oop1
Oop1Oop1
Oop1
 
The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
Project_Euler_No_104_Pandigital_Fibonacci_ends
Project_Euler_No_104_Pandigital_Fibonacci_endsProject_Euler_No_104_Pandigital_Fibonacci_ends
Project_Euler_No_104_Pandigital_Fibonacci_ends
 
Code optimization
Code optimization Code optimization
Code optimization
 
Static and const members
Static and const membersStatic and const members
Static and const members
 
Lec21-CS110 Computational Engineering
Lec21-CS110 Computational EngineeringLec21-CS110 Computational Engineering
Lec21-CS110 Computational Engineering
 
The Ring programming language version 1.2 book - Part 42 of 84
The Ring programming language version 1.2 book - Part 42 of 84The Ring programming language version 1.2 book - Part 42 of 84
The Ring programming language version 1.2 book - Part 42 of 84
 
The Ring programming language version 1.5.3 book - Part 41 of 184
The Ring programming language version 1.5.3 book - Part 41 of 184The Ring programming language version 1.5.3 book - Part 41 of 184
The Ring programming language version 1.5.3 book - Part 41 of 184
 

Similaire à Smart Contract samples

Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented NetworkingMostafa Amer
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo....NET Conf UY
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBtdc-globalcode
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy codeShriKant Vashishtha
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEDarwin Durand
 
TDC2016SP - Trilha .NET
TDC2016SP - Trilha .NETTDC2016SP - Trilha .NET
TDC2016SP - Trilha .NETtdc-globalcode
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo Ali Parmaksiz
 
重構—改善既有程式的設計(chapter 8)part 1
重構—改善既有程式的設計(chapter 8)part 1重構—改善既有程式的設計(chapter 8)part 1
重構—改善既有程式的設計(chapter 8)part 1Chris Huang
 
Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8RichardWarburton
 
Finishing the App - Part 1.pdf
Finishing the App - Part 1.pdfFinishing the App - Part 1.pdf
Finishing the App - Part 1.pdfShaiAlmog1
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8Dhaval Dalal
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Codemotion
 
Introduction à Dart
Introduction à DartIntroduction à Dart
Introduction à DartSOAT
 
Creating an Uber Clone - Part XXIX - Transcript.pdf
Creating an Uber Clone - Part XXIX - Transcript.pdfCreating an Uber Clone - Part XXIX - Transcript.pdf
Creating an Uber Clone - Part XXIX - Transcript.pdfShaiAlmog1
 
Java весна 2013 лекция 3
Java весна 2013 лекция 3Java весна 2013 лекция 3
Java весна 2013 лекция 3Technopark
 
Spca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_serviceSpca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_serviceNCCOMMS
 
Creating a Facebook Clone - Part XXVI - Transcript.pdf
Creating a Facebook Clone - Part XXVI - Transcript.pdfCreating a Facebook Clone - Part XXVI - Transcript.pdf
Creating a Facebook Clone - Part XXVI - Transcript.pdfShaiAlmog1
 
Presentation Android Architecture Components
Presentation Android Architecture ComponentsPresentation Android Architecture Components
Presentation Android Architecture ComponentsAttract Group
 

Similaire à Smart Contract samples (20)

Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented Networking
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 
TDC2016SP - Trilha .NET
TDC2016SP - Trilha .NETTDC2016SP - Trilha .NET
TDC2016SP - Trilha .NET
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
 
重構—改善既有程式的設計(chapter 8)part 1
重構—改善既有程式的設計(chapter 8)part 1重構—改善既有程式的設計(chapter 8)part 1
重構—改善既有程式的設計(chapter 8)part 1
 
Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8
 
Finishing the App - Part 1.pdf
Finishing the App - Part 1.pdfFinishing the App - Part 1.pdf
Finishing the App - Part 1.pdf
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8
 
Jersey Guice AOP
Jersey Guice AOPJersey Guice AOP
Jersey Guice AOP
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
Introduction à Dart
Introduction à DartIntroduction à Dart
Introduction à Dart
 
Creating an Uber Clone - Part XXIX - Transcript.pdf
Creating an Uber Clone - Part XXIX - Transcript.pdfCreating an Uber Clone - Part XXIX - Transcript.pdf
Creating an Uber Clone - Part XXIX - Transcript.pdf
 
Java весна 2013 лекция 3
Java весна 2013 лекция 3Java весна 2013 лекция 3
Java весна 2013 лекция 3
 
slides
slidesslides
slides
 
Spca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_serviceSpca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_service
 
Creating a Facebook Clone - Part XXVI - Transcript.pdf
Creating a Facebook Clone - Part XXVI - Transcript.pdfCreating a Facebook Clone - Part XXVI - Transcript.pdf
Creating a Facebook Clone - Part XXVI - Transcript.pdf
 
Presentation Android Architecture Components
Presentation Android Architecture ComponentsPresentation Android Architecture Components
Presentation Android Architecture Components
 

Plus de NexThoughts Technologies (20)

Alexa skill
Alexa skillAlexa skill
Alexa skill
 
GraalVM
GraalVMGraalVM
GraalVM
 
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
 
Apache commons
Apache commonsApache commons
Apache commons
 
HazelCast
HazelCastHazelCast
HazelCast
 
MySQL Pro
MySQL ProMySQL Pro
MySQL Pro
 
Microservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & ReduxMicroservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & Redux
 
Swagger
SwaggerSwagger
Swagger
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Arango DB
Arango DBArango DB
Arango DB
 
Jython
JythonJython
Jython
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
My Doc of geth
My Doc of gethMy Doc of geth
My Doc of geth
 
Geth important commands
Geth important commandsGeth important commands
Geth important commands
 
Ethereum genesis
Ethereum genesisEthereum genesis
Ethereum genesis
 
Ethereum
EthereumEthereum
Ethereum
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
Google authentication
Google authenticationGoogle authentication
Google authentication
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 

Dernier

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Dernier (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Smart Contract samples

  • 1. Adder pragma solidity ^0.4.2; contract adder{ string name; function setName(string _name) public { name = _name; } function getName() constant returns (string){ return name; } function add(int a, int b){ return a+b; } } GreeterSample pragma solidity ^0.4.2; contract greeter{ string greeting; constructor(string _greeting) public{ greeting = _greeting; } function greet() constant public returns (string){ return greeting; } function setGreeting(string _greeting) public{ greeting = _greeting; } function greet2() constant public returns (string){ return "ethereum sample"; } } AuditLogSample pragma solidity ^​0.4.2​; contract auditlog{ string uid; string audit; string date;
  • 2. function​ ​auditlog​(​string _uid, string _audit, string _date​){ uid= _uid; audit= _audit; date= _date; } function​ ​getUid​() ​constant​ ​returns​ (​string​){ return​ uid; } function​ ​getAudit​() ​constant​ ​returns​ (​string​){ return​ audit; } function​ ​getDate​() ​constant​ ​returns​ (​string​){ return​ date; } } VotingSample pragma solidity ^​0.4.18​; contract Voting { mapping (​bytes32​ => uint8) public votesReceived; bytes32[] public candidateList; ​function​ ​Voting​(​bytes32[] candidateNames​) ​public​ { candidateList = candidateNames; } function​ ​totalVotesFor​(​bytes32 candidate​) ​view​ ​public​ ​returns​ (​uint8​) { ​require​(validCandidate(candidate)); ​return​ votesReceived[candidate]; } ​function​ ​voteForCandidate​(​bytes32 candidate​) ​public​ { ​require​(validCandidate(candidate)); votesReceived[candidate] += ​1​; } ​function​ ​validCandidate​(​bytes32 candidate​) ​view​ ​public​ ​returns​ (​bool​) { ​for​(uint i = ​0​; i < candidateList.length; i++) { ​if​ (candidateList[i] == candidate) { ​return​ ​true​; } } return​ ​false​; } } FeverContract pragma solidity ^​0.4.17​;
  • 3. contract FeverContract { uint8 temperature; ​function​ ​FeverContract​(){ temperature = ​98​; } ​function​ ​getTemperature​() ​public​ ​constant​ ​returns​ (​uint8​) { ​return​ temperature; } ​function​ ​hasFever​() ​public​ ​constant​ ​returns​ (​bool​) { ​return​ temperature > ​100​; } ​function​ ​increaseTemp​() ​public​ ​returns​ (​uint8​) { ​if​ (temperature > ​110​) revert(); temperature += ​1​; ​return​ temperature; } ​function​ ​decreaseTemp​() ​public​ ​returns​ (​uint8​) { ​if​ (temperature < ​95​) revert(); temperature -= ​1​; ​return​ temperature; } }