Ethereum Oracle Services — Getting data into your dApp

dAppBridge - Ethereum Oracle
2 min readJun 8, 2018

--

Feeding data back into your dApp/Smart Contract

A Ethereum Oracle is a service that allows you to take data from the Internet (Or another source external to the blockchain) and feed it into your dApp or Smart Contract.

This is something which isn’t baked into Solidity or Smart Contracts — so you have to use an external provider (Or build it yourself).

dAppBridge provides what we believe to be the simplest way possible to get external data into your dApp. Although simple — the dAppbridge Ethereum Oracle is extremely powerful (See https://dappbridge.com for full details of the extensive range of features.

Using the dAppBridge Oracle to get data into your dApp

There are 2 main parts to getting data into your smart contract using any Ethereum Oracle…

  1. A request to the data
  2. A callback function that receives the data

We’ve simplified both!

  1. Requesting data

In this example we are going to request a simple random number — something which can be difficult to do on a decentralised blockchain. The simple request is:

bytes32 newkey = randomNumber("callback", 1, 100, 0);

As simple as that! This will request a random number between 1 and 100 as soon as possible (The 0 parameter is a timer)… the result will be passed to our function named “callback”.

The response from this is a handy unique key — unique for every request you make, allowing you to tie each response back to the original request.

2. Receiving the data

Again — very simple when using the dAppBridge Ethereum Oracle… the callback function is called by the dAppBridge service (And can only be called by the dAppBridge service due to the protection offered by the only_dAppBridge modifier):

function callback(bytes32 key, int callbackData) external payable only_dAppBridge {
...
}

As you can see — the key is passed in, along with you random number (callbackData param).

Putting this all together in a simple smart contract would look something like:

This is a simple example but shows you the power of using the dAppBridge Ethereum Oracle!

Find out more at: https://dappbridge.com

Get in touch

Let us know how your using dAppBridge, if you have any questions or need any help! dapps@dappbridge.com or https://twitter.com/dappbridge

--

--