Oracles on the Waves Platform

Marc Jansen
Aug 14 · 5 min read
Figure 1 — Landing page for the Oracle infrastructure on the Waves Platform
Figure 2 — Form for the creation of an Oracle
Figure 3 — Definition of parameters
import pywaves as pw
import requests
import time

def getData():
res = requests.get('https://api.royaleapi.com/player/<player id>', headers = { 'auth': '<auth key for the API>' })
data = res.json()

return { 'trophies': data['trophies'], 'arena': data['arena']['arenaID'] }

def writeData(data):
pw.setNode('http://waves.dsalab.de:6869', 'testnet')
address = pw.Address(seed = '<seed of the Oracle address>')
now = round(time.time() * 1000)
tx = address.dataTransaction([
{ "key": "trohpies", "value": data['trophies'], "type": "integer" },
{ "key": "arena", "value": data['arena'], "type": "integer" },
{ "key": "wpo_updatedate", "value": now, "type": "integer" },
])
print(tx)

data = getData()
writeData(data)
Figure 4 — Data of the Oracle
Figure 5 — Timestamp of the last update of the Oracle (wpo_updatedate)

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade