SlideShare a Scribd company logo
ORACLES
Role of blockchain oracles
Oracle demo
5/7/2020
CONSULTING THE ORACLE
DEFINITION
Blockchain Oracles are third-party services that
provide smart contracts with external information.
They serve as bridges between blockchains and
the outside world.
WHAT ORACLES DO?
Provide information to the smart contracts on the blockchain
Translate information from outside platforms
Trigger smart contracts
Deliver information from smart contracts to outside world
ORACLES ON ETHEREUM
Ethereum
Network
Stock
Market
Data
Currency
Exchange
Rates
Bank
payments
Other
blockchains
Web API
IOT Events
MANY TYPES OF ORACLES
Software
Oracles
Inbound
Oracles
Hardware
Oracles
Outbound
Oracles
Consensus-
based Oracles
DEMO
Use case
Create oracle contract and
deploy to blockchain
Configure event listener
on IoT device
OPEN SESAME!
USE CASES
Seller
Put treasure is safe
Lock safe
Set unlock price in
smart contract
Pay on blockchain to
smart contract
Open safe
Get treasure
Buyer
ARCHITECTURE
User Interface Blockchain Raspberry Pi Safe
CREATE SMART CONTRACT IN
REMIX
OPEN SESAME SMART
CONTRCT
Oracle
SMART CONTRACT
pragma solidity >=0.4.22 <0.6.0;
contract OpenSesame{
enum State { Locked, Unlocked }
State public state;
uint public value; //value to unlock
address payable public seller;
event Unlock();
event Lock();
…
SMART CONTRACT (UNLOCK AND
LOCK FUNCTIONS)
function unlock()
public
inState(State.Locked)
condition(msg.value >
value)
payable
{
state = State.Unlocked;
emit Unlock();
}
function lock(uint _value)
public
onlySeller
inState(State.Unlocked)
{
value = _value;
state = State.Locked;
emit Lock();
}
DEPLOY TO TEST
NETWORK
GENERATE MNEMONIC
LOG IN TO METAMASK
CONNECT REMIX TO METAMASK
GET SOME TEST ETHER (1ETH)
COMPILE THE CONTRACT
REQUEST PUBLISHING THE
CONTRACT TO ROPSTEN TEST
NETWORK
AND “PAY” FOR PUBLISHING THE
CONTRACT
WAIT FOR THE CONTRACT TO BE
PUBLISHED
PAY >1000 WEI TO UNLOCK
CONFIRM SENDING TRANSACTION
TO UNLOCK
CONFIRM ON ETHERSCAN THAT
EVENT WAS CREATED
LOCK AND SET UNLOCK FEE TO
10,000 WEI
CHECK THAT THE STATE IS 0
(LOCKED) AND VALUE IS SET TO
10,OOO (WEI)
IOT SIDE Raspberry PI
RASPBERRY PI • Raspbian OS
• NodeJS
• Web3JS Node module
• Onoff Node module
SCHEMATICS AND REALITY
GET BALANCE ON SESAME
CONTRACT
const Web3 = require("web3")
const web3 = new Web3(new
Web3.providers.HttpProvider("https://ropsten.infura.io/v3/edb1d45f792244bfa97c13d84
a809090"))
web3.eth.getBalance("0x126A01a11b7fD2a4C7c62887af21D2C69FB29bd5", function(err,
result) {
if (err) {
console.log(err);
} else {
console.log("Account balance: " + result + " [WEI]");
}
})
LISTEN TO SESAME’S EVENTS
const Web3 = require("web3");
const fs = require('fs’);
const contractAddress =
"0x032D472C05ff870cf800dbaD
4B14A50c031432aB";
const web3 = new Web3(new
Web3.providers.WebsocketProvid
er("wss://ropsten.infura.io/ws/v
3/edb1d45f792244bfa97c13d84
a809090"))
var myContract = new
web3.eth.Contract(JSON.parse(ab
i), contractAddress);
console.log("Listening for events
on", contractAddress);
myContract.events.allEvents()
.on('data', (event) => {
console.log(event);
})
.on('error', console.error);
UNLOCK EVENT
LOCK EVENT
STAY IN TOUCH
Gene Leybzon https://www.linkedin.com/in/leybzon/
https://www.meetup.com/members/90744
20/
https://www.leybzon.com
CODE FOR THE EVENT LISTENER
1/3const Web3 = require("web3");
const fs = require('fs');
var Gpio = require('onoff').Gpio; //include onoff to interact with the GPIO
var LED = new Gpio(23, 'out'); //use GPIO pin 18, and specify that it is output
var blinkInterval = setInterval(blinkLED, 250); //run the blinkLED function every 250ms
const contractAddress = "0x032D472C05ff870cf800dbaD4B14A50c031432aB";
function blinkLED() { //function to start blinking
if (LED.readSync() === 0) { //check the pin state, if the state is 0 (or off)
LED.writeSync(1); //set pin state to 1 (turn LED on)
} else {
LED.writeSync(0); //set pin state to 0 (turn LED off)
}
}
CODE FOR THE EVENT LISTENER
2/3function endBlink() { //function to stop blinking
clearInterval(blinkInterval); // Stop blink intervals
LED.writeSync(0); // Turn LED off
//LED.unexport(); // Unexport GPIO to free resources
}
endBlink();
var abi = fs.readFileSync('OpenSesame_sol_OpenSesame.abi', 'utf8');
//console.log("ABI", abi);
const web3 = new Web3(new
Web3.providers.WebsocketProvider("wss://ropsten.infura.io/ws/v3/edb1d45f792244bfa97c13d84
a809090"))
var myContract = new web3.eth.Contract(JSON.parse(abi), contractAddress);
console.log("Listening for events on", contractAddress);
CODE FOR THE EVENT LISTENER
3/3myContract.events.allEvents()
.on('data', (event) => {
console.log("Event:", event);
console.log("Event Type:", event.event);
if (event.event == "Unlock") {
console.log("Will unlock the safe");
blinkLED();
}
if (event.event == "Lock") {
console.log("Will lock the safe");
endBlink();
}
})
.on('error', console.error);

More Related Content

PPTX
Ethereum Web3.js - Some tips for the developer
PDF
How to be a smart contract engineer
PDF
Bitcoin 技術介紹
PPTX
Ethereum Smart Contract Tutorial
PPTX
Ethereummeetuppresentation01 170105172132
PDF
Token platform based on sidechain
PPTX
Developing your first application using FIWARE
PPTX
Eclipsecon Europe: Blockchain, Ethereum and Business Applications
Ethereum Web3.js - Some tips for the developer
How to be a smart contract engineer
Bitcoin 技術介紹
Ethereum Smart Contract Tutorial
Ethereummeetuppresentation01 170105172132
Token platform based on sidechain
Developing your first application using FIWARE
Eclipsecon Europe: Blockchain, Ethereum and Business Applications

Similar to Oracles (20)

PPTX
Introduction to Things board (An Open Source IoT Cloud Platform)
PDF
Blockchain com JavaScript
PDF
Building decentralised apps with js - Devoxx Morocco 2018
PDF
Nodejs and WebSockets
PDF
web3j Overview
PDF
Socket.IO - Alternative Ways for Real-time Application
PDF
Solidity Contract: the code, compilation, deployment and accessing
PDF
WebSockets Jump Start
PDF
Demystifying Apple 'Pie' & TouchID
PDF
Smart contracts using web3.js
PDF
Java and the blockchain - introducing web3j
ODP
Building Websocket Applications with GlassFish and Grizzly
PPTX
Html5 websockets
PPTX
presentation in .net programming web sockets.pptx
PDF
FIWARE Internet of Things
PDF
FIWARE Internet of Things
PDF
Building interactivity with websockets
PDF
Flowchain: A case study on building a Blockchain for the IoT
PDF
Programming IoT Gateways in JavaScript with macchina.io
PDF
FIWARE Global Summit - The Role of Blockchain in “Powered by FIWARE” Architec...
Introduction to Things board (An Open Source IoT Cloud Platform)
Blockchain com JavaScript
Building decentralised apps with js - Devoxx Morocco 2018
Nodejs and WebSockets
web3j Overview
Socket.IO - Alternative Ways for Real-time Application
Solidity Contract: the code, compilation, deployment and accessing
WebSockets Jump Start
Demystifying Apple 'Pie' & TouchID
Smart contracts using web3.js
Java and the blockchain - introducing web3j
Building Websocket Applications with GlassFish and Grizzly
Html5 websockets
presentation in .net programming web sockets.pptx
FIWARE Internet of Things
FIWARE Internet of Things
Building interactivity with websockets
Flowchain: A case study on building a Blockchain for the IoT
Programming IoT Gateways in JavaScript with macchina.io
FIWARE Global Summit - The Role of Blockchain in “Powered by FIWARE” Architec...
Ad

Recently uploaded (20)

PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
AutoCAD Professional Crack 2025 With License Key
PPTX
assetexplorer- product-overview - presentation
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Website Design Services for Small Businesses.pdf
CHAPTER 2 - PM Management and IT Context
Oracle Fusion HCM Cloud Demo for Beginners
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Patient Appointment Booking in Odoo with online payment
AutoCAD Professional Crack 2025 With License Key
assetexplorer- product-overview - presentation
Design an Analysis of Algorithms I-SECS-1021-03
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Complete Guide to Website Development in Malaysia for SMEs
Autodesk AutoCAD Crack Free Download 2025
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
17 Powerful Integrations Your Next-Gen MLM Software Needs
wealthsignaloriginal-com-DS-text-... (1).pdf
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Salesforce Agentforce AI Implementation.pdf
Designing Intelligence for the Shop Floor.pdf
Website Design Services for Small Businesses.pdf
Ad

Oracles

  • 1. ORACLES Role of blockchain oracles Oracle demo 5/7/2020
  • 3. DEFINITION Blockchain Oracles are third-party services that provide smart contracts with external information. They serve as bridges between blockchains and the outside world.
  • 4. WHAT ORACLES DO? Provide information to the smart contracts on the blockchain Translate information from outside platforms Trigger smart contracts Deliver information from smart contracts to outside world
  • 6. MANY TYPES OF ORACLES Software Oracles Inbound Oracles Hardware Oracles Outbound Oracles Consensus- based Oracles
  • 7. DEMO Use case Create oracle contract and deploy to blockchain Configure event listener on IoT device
  • 9. USE CASES Seller Put treasure is safe Lock safe Set unlock price in smart contract Pay on blockchain to smart contract Open safe Get treasure Buyer
  • 13. SMART CONTRACT pragma solidity >=0.4.22 <0.6.0; contract OpenSesame{ enum State { Locked, Unlocked } State public state; uint public value; //value to unlock address payable public seller; event Unlock(); event Lock(); …
  • 14. SMART CONTRACT (UNLOCK AND LOCK FUNCTIONS) function unlock() public inState(State.Locked) condition(msg.value > value) payable { state = State.Unlocked; emit Unlock(); } function lock(uint _value) public onlySeller inState(State.Unlocked) { value = _value; state = State.Locked; emit Lock(); }
  • 17. LOG IN TO METAMASK
  • 18. CONNECT REMIX TO METAMASK
  • 19. GET SOME TEST ETHER (1ETH)
  • 21. REQUEST PUBLISHING THE CONTRACT TO ROPSTEN TEST NETWORK
  • 22. AND “PAY” FOR PUBLISHING THE CONTRACT
  • 23. WAIT FOR THE CONTRACT TO BE PUBLISHED
  • 24. PAY >1000 WEI TO UNLOCK
  • 26. CONFIRM ON ETHERSCAN THAT EVENT WAS CREATED
  • 27. LOCK AND SET UNLOCK FEE TO 10,000 WEI
  • 28. CHECK THAT THE STATE IS 0 (LOCKED) AND VALUE IS SET TO 10,OOO (WEI)
  • 30. RASPBERRY PI • Raspbian OS • NodeJS • Web3JS Node module • Onoff Node module
  • 32. GET BALANCE ON SESAME CONTRACT const Web3 = require("web3") const web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/edb1d45f792244bfa97c13d84 a809090")) web3.eth.getBalance("0x126A01a11b7fD2a4C7c62887af21D2C69FB29bd5", function(err, result) { if (err) { console.log(err); } else { console.log("Account balance: " + result + " [WEI]"); } })
  • 33. LISTEN TO SESAME’S EVENTS const Web3 = require("web3"); const fs = require('fs’); const contractAddress = "0x032D472C05ff870cf800dbaD 4B14A50c031432aB"; const web3 = new Web3(new Web3.providers.WebsocketProvid er("wss://ropsten.infura.io/ws/v 3/edb1d45f792244bfa97c13d84 a809090")) var myContract = new web3.eth.Contract(JSON.parse(ab i), contractAddress); console.log("Listening for events on", contractAddress); myContract.events.allEvents() .on('data', (event) => { console.log(event); }) .on('error', console.error);
  • 36. STAY IN TOUCH Gene Leybzon https://www.linkedin.com/in/leybzon/ https://www.meetup.com/members/90744 20/ https://www.leybzon.com
  • 37. CODE FOR THE EVENT LISTENER 1/3const Web3 = require("web3"); const fs = require('fs'); var Gpio = require('onoff').Gpio; //include onoff to interact with the GPIO var LED = new Gpio(23, 'out'); //use GPIO pin 18, and specify that it is output var blinkInterval = setInterval(blinkLED, 250); //run the blinkLED function every 250ms const contractAddress = "0x032D472C05ff870cf800dbaD4B14A50c031432aB"; function blinkLED() { //function to start blinking if (LED.readSync() === 0) { //check the pin state, if the state is 0 (or off) LED.writeSync(1); //set pin state to 1 (turn LED on) } else { LED.writeSync(0); //set pin state to 0 (turn LED off) } }
  • 38. CODE FOR THE EVENT LISTENER 2/3function endBlink() { //function to stop blinking clearInterval(blinkInterval); // Stop blink intervals LED.writeSync(0); // Turn LED off //LED.unexport(); // Unexport GPIO to free resources } endBlink(); var abi = fs.readFileSync('OpenSesame_sol_OpenSesame.abi', 'utf8'); //console.log("ABI", abi); const web3 = new Web3(new Web3.providers.WebsocketProvider("wss://ropsten.infura.io/ws/v3/edb1d45f792244bfa97c13d84 a809090")) var myContract = new web3.eth.Contract(JSON.parse(abi), contractAddress); console.log("Listening for events on", contractAddress);
  • 39. CODE FOR THE EVENT LISTENER 3/3myContract.events.allEvents() .on('data', (event) => { console.log("Event:", event); console.log("Event Type:", event.event); if (event.event == "Unlock") { console.log("Will unlock the safe"); blinkLED(); } if (event.event == "Lock") { console.log("Will lock the safe"); endBlink(); } }) .on('error', console.error);

Editor's Notes

  • #3: John William Waterhouse, 1884
  • #6: https://www.buybitcoinworldwide.com/ethereum/mining-pools/
  • #7: http://blockchainhub.net/blockchain-oracles/
  • #9: https://me.me/i/his-password-was-crypt-ic-bizarrocomics-com-open-sesame-our-uername-your-username-18507547
  • #12: https://remix.ethereum.org/
  • #15: https://github.com/leybzon/solidity-baby-steps/blob/master/contracts/95_open_sesame.sol
  • #17: https://iancoleman.io/bip39/
  • #19: We use Ropsten Test Network
  • #20: https://faucet.ropsten.be/
  • #33: pi@raspberrypi:~ $ node app.js Account balance: 10000 [WEI]