Hot answers tagged

89

You can use an Oracle. An oracle is any device or entity that connects real-world data with the blockchain. There are several examples of oracle technologies. Chainlink and Provable (formerly Oraclize) are two examples that do exactly that. There are some code examples here as well as the documentation of our Solidity API. Oraclize is available both on ...


41

You can't do this directly; Ethereum contracts can't hit URLs, because Ethereum needs everyone to be able to independently validate the outcome of running any given contract, and you can't guarantee that they'd all get the same result from any given URL. What you can do is get some third-party, or a combination of third-parties, to hit the URL for you and ...


35

Edmund Edgar from Reality Keys here. Basically what needs to happen is that somebody says what data they want, the trusted service provides an ID that identifies it (in our case a hash of the data) and a key they'll sign the result with, and somebody sends a transaction to the contract. Then we wait for the result. Once the result is known, the trusted ...


32

It is very possible to use the Oraclize service with testrpc alongside truffle. Firstly, you need to follow the naming convention of contract filenames in truffle. As per their docs: Truffle expects your contract files to define contracts that match their filenames exactly Therefore you should download the Oraclize API from the Oraclize github repo, ...


26

Oraclize stores the TLSnotary secret in an Amazon Web Services (AWS) Virtual Machine. Using the techniques described here, they are able to provide some additional guarantees regarding the software running in the AWS instance and when/whether it has been modified since being initialised. The "proofs of honesty" they provide (and allow you to verify with ...


26

I'll take a stab at a very high-level overview by describing a generalized goal, the limitations of Smart Contracts, and the outlines of a solution. This will hopefully provide some context for the implementation details. 1) The goal. A Smart Contract that can react to an observable event or data point in the universe. With so much data sloshing about on ...


14

Thomas from Oraclize here. You probably are having this issue because you are not sending any value along. The Oraclize API calls come at a cost, the small fee we charge is paid in advance when calling oraclize_query. The first API call from each contract is free, so this is why your first call is working. Please check out our pricing here. This applies to ...


14

This blog post (old since default gas price is currently 0.02 szabos) from Stephan Tual has the hint: The default gas price is set at 50 shannon (0.05 szabos, or 0.00000005 ether). Remember that the gas price is ultimately always defined by the users calling a contract, while the miners can set a parameter on their machines to accept or ignore ...


14

A blockchain oracle is any device or entity that connects a deterministic blockchain with off-chain data. Smart contracts cannot make API calls themselves because they are deterministic, but without being able to interact with data the lives off-chain, they won't be able to utilize the decentrality, security, and reliability a smart contract has. To get data ...


11

Thomas from Oraclize here. When you call Oraclize the query is asynchronous, this means that one transaction is needed to send the query and another transaction to receive the result - this is the "callback transaction", it's sent by Oraclize and usually comes ~1-2 blocks after the first one. The "callback transaction" is calling the __callback method as ...


11

They have themselves a contract that interfaces with the real world. you register with their contract and define a function they should call their contract is read by an external entity, that sees your "query" the external entity executes the query (eg. calling random.org) calls your callback function either directly or through their contract profit ;-)


10

A detailed tutorial for how a contract can obtain data has been written for the Python Ethereum client (pyethapp): https://github.com/ethereum/pyethapp/wiki/Making-a-User-Service:-Tutorial One of pyethapp's most powerful distinguishing features is its ability to easily create built-in user services: scripts written in python that run alongside ...


9

Smart contracts will contact the physical world in a similar way that the Internet calls the physical world. The Internet doesn't call the world: the world watches the Internet then acts. Similarly, the public Ethereum network and blockchain will not call the world: the world will watch it then act. Smart contracts can trigger events, and those that are ...


8

Thomas from Oraclize here. One simple yet quite secure way to get a Bitcoin reference price into your contract is to use existing exchanges as datasources thanks to their APIs. I suppose here that what you want is BTCUSD, if it was BTCETH instead than minor code changes are required but the same reasoning applies. Doing that in Solidity via Oraclize is ...


8

Miners never make external calls on behalf of your contracts. Oracles are done by a user (or machine, of course) sending a tx into the Oracle contract putting the data there. Your contract then reads the data from the Oracle contract, not from the off-blockchain world. The data from the external source may be non-deterministic, but once it's on the ...


8

now is a Solidity special variable, which equates to the current time since the epoch, in seconds. From the documentation (linked above): now (uint): current block timestamp (alias for block.timestamp)


8

On mainnet, sponsors are paying the LINK associated to keep those feeds live, decentralized, and secure, so they are not free. This allows the network to be a shared resource where everyone chips in a tiny bit and makes them even cheaper than running even your own centralized feed. That being said, the price feeds are currently a simple view function, and ...


7

Codius is/was a offchain smart oracle platform. These are basically sandboxed virtual machines running Google’s Native Client. The sandboxed VMs can be paid to run untrusted native code and to report the results to some underlying consensus system (ethereum, bitcoin, ripple) signing these transactions. You then choose to trust the results provided by a super ...


7

Yes, that's absolutely possible. Using some specific service is the way of centralization. Since then, you depend on it. They can pass whatever data they want. One of the ways to solve an issue is to use multiple services and majority vote of them.


6

The oracle problem is: "If oracles allow corrupt data to be imported on-chain, auto-executing smart contracts can have disastrous affects" Once data is reported to a blockchain, that data is now an immutable part of the history of the blockchain. If a smart contract executes incorrectly based off that data, your contract is not only not doing what ...


6

The basic ideas of blockchain remains the same in Ethereum 2.0; one of the basic concepts is they are deterministic. For our purposes that means that external data needs to be input into the blockchain. The way to do that is through various kinds of oracles. So that will not change for Eth 2.0. External data still needs to come somehow into the blockchain ...


5

As @Thomas Bertani mentions in the comment, Oraclize can be used directly in MyContract. If you need to use 2 contracts, expanding on his comment, then you need to create a setter, and invoke the setter on a specific instance of MyContract. Example: contract MyContract { uint public BTCUSD; function set(uint val) { BTCUSD = val; } } contract ...


5

Ultimately you're going to be relying on somebody to tell the truth, because somebody is going to have to be in charge of the thermometer. The information from the thermometer then needs to be transmitted to your Ethereum contract in such a way that the contract can believe it came from the thermometer: Some computer somewhere owned by someone will either ...


5

As others have stated, you must use an Oracle. Some projects like ChainLink and Oracleize will do this for you. To set up an oracle on your own, the process looks like this: Create a smart contract Setup a server listening for some external event, eg a sports game Once a particular condition is met, eg one team wins, your server will send a transaction to ...


5

An oracle can be a manually controlled human account that feeds data in a timely manner or better an automated bunch of bots on traditional servers that scrape a website and feeds in data via the account. You'd need to hard code a contract address into your contract as an oracle of truthful values for your programme. The private key is kept private, unlike a ...


5

That line is meant to be replaced with the actual content of the Oraclize api.sol file (or to your local path to the api.sol file) so.. get rid of the "import .." line and copy paste the http://dev.oraclize.it/api.sol (which is the same as the one on github) file content there. This process is not needed while using our dev.oraclize.it web-based IDE (since ...


5

No, that's not how Oraclize works. You send an API call to Oraclize contract Oraclize has a node monitoring the contract Oraclize does the query off-chain Oraclize sends a tx calling your _callback function with the result of the API call So none of the nodes or miners call an external service, Oraclize puts the data on the chain once


5

It's worth noting that miners can manipulate now and so it shouldn't be relied upon for anything sensitive such as seeding Psuedo-Random Number Generators.


Only top voted, non community-wiki answers of a minimum length are eligible