Obligacje skarbowe - czym są i jak działa rentowność?

Published: 2025-04-09 15 minut
Category:
finanse
▪ Tags:
obligacje

Dowiedz się, czym są obligacje skarbowe. Zrozum, jak zmienia się rentowność obligacji, w zależności od jej ceny. Dlaczego rentowność maleje albo rośnie?

How do you read data outside the blockchain in a contract and how do Oracles work?

Smart blockchain contracts are limited to reading data only from the blockchain, i.e. those written in the block. How to provide data from outside the blockchain to the contract?

Oracles, is a well-known term for the mechanism by which a contract reads data from outside the blockchain. How does it work? This mechanism, or rather design pattern, DOES NOT have the ability to exceed the limitations of the blockchain. This means that oracles cannot read files, databases, or external services (APIs) directly. The oracle design pattern, however, makes it possible to “provide” external data to the blockchain. How?

External data to the smart contract (from outside the blockchain) can be provided only, as parameters (arguments) of its call. Oracles are software running outside the blockchain, which listens for “requests” by smart contracts for external data, and then provides this data to the smart contract, by calling the appropriate function of the contract, which will write this data to the blockchain. A smart contract, for example, has the ability to make a programmed off-chain (oracle) query for data from a certain API (e.g., BTC/PLN prices). The oracle software executes the query off the blockchain and then returns the result to the contract, calling its corresponding function with the result. In this way, the contract will “receive” data from outside, the execution will be automatic, but the mechanism itself is no different from manually calling the contract function, which writes the data to the blockchain, so that the contract can read it on its own.

Many myths have grown up around the topic of oracle, but the technical aspect of providing data to the blockchain itself is simple and does not cross the underlying technological barriers (e.g. Ethereum). It is worth knowing this when designing web3 solutions, as it has its limitations. Now that it’s known how to deliver data to the blockchain, it’s worth asking how to deliver data that is “correct”, true, and in a decentralized manner, consistent with the implementation of web3 solutions? This is a broad, difficult, but interesting topic.

How to achieve decentralization using Oracles in blockchain?

How to achieve decentralization using Oracles in blockchain and why is it harder than most of the industry thinks?

Oracles allow you to read data from outside the blockchain in contracts (smart contracts). This is an important functionality practically, because building a web3 application using contracts without data from outside the blockchain (e.g., currency pair prices) severely limits the ability to implement complex business logic in contracts.

The industry unfortunately has a misconception about how oracle works. It is assumed that the mechanism is “decentralized,” while practically the opposite is very often true.

In the basic model of oracle use, the contract has the ability to query data from outside, and the oracle executes this query (e.g., reading from a database) and returns the result to the contract. However, this is a completely centralized model. Why? Because the result delivered to the contract comes only from one oracle. Using oracle creation technologies, we can literally run our own oracle, which, for our blockchain solution, will be responsible for providing data from outside the blockchain. This model is inexpensive and is the primary way to execute an oracle query using Chainlink – the largest blockchain project providing oracle technology for contracts.

So how do we create a decentralized oracle? The model is as follows: a contract should ask several oracles to execute the same query, get results from each oracle, and then determine the correct answer on its own based on multiple results (answers from multiple oracles). This is difficult and has a lot of challenges. First of all, the way to determine the target value based on multiple answers is not obvious – when asking, for example, the USD/BTC price of three oracles, we can count the average of the results in the contract. However, it is not always so simple.

The use of several oracles is a correspondingly higher cost. Each query costs money, so when deciding on a form of “decentralization” at this level, we have to reckon with a higher cost of handling contracts. Contract developers, therefore, often don’t do this, relying on a single oracle. When creating a thoughtful web3 solution, this is unfortunately unacceptable.

Do oracles have to return correct data? Even if I use several of them and achieve decentralization by relying on multiple oracles, how can I be sure that the data they return is correct? The answer is not simple.

Optimal strategy for safe Oracles use in web3

Does the data provided to smart contracts by oracles have to be correct? No 😉 What are the risks and what strategy to adopt when designing a web3 solution?

Oracles provide data from outside the blockchain to contracts (smart contract). This is an important functionality, because without it, contracts are limited to blockchain data only. Oracles therefore enable the implementation of complex business logic in web3 solutions.

In previous articles, I discussed the basic operation of oracles. The decentralized oracle model involves querying data from outside several independent oracles, and then determining the right one based on their answers (several). Asking, for example, the USD/BTC price of three oracles, the final value is perhaps the average of the 3 answers obtained.

But do the oracles have to return the correct result? If the correct operation of the contract depends on it, then this is one of the most important factors determining the sense of using oracles. Unfortunately, from a technical point of view, oracles do not have to return correct answers. The correctness of the data returned by oracles is based on cryptoeconomics – the most popular model for ensuring “correctness” used in the blockchain world.

This is the basis of blockchain cryptoeconomics: oracles return correct data because it pays them to do so, and an incorrect answer can be very costly. The oracle’s business model is to execute off-chain (off-blockchain) queries and return them to the contract in exchange for a fee, which the contract pays by asking oracles for off-chain data. The execution of a “bad” service by an oracle will result in a loss of reputation and, in extreme cases, may even end in the loss of a security deposit (e.g., one that the oracle must deposit at the beginning in order to start providing services on the network at all (analogous to staking).

However, it is worth knowing that an oracle has the possibility to return a wrong answer. Depending on the level of security of a given technology for the oracle (e.g. Chainlink) – such an oracle may incur a greater or lesser penalty, but technically it is very difficult to stop the oracle from “lying”. The model is the safer, the more severe the economic penalty (loss) the oracle will incur when it lies. Therefore, the strong token on which the oracle ecosystem is based should be “valuable”.

Using multiple oracles and relying on those with a good reputation – this is the optimal strategy for using oracles. However, this is an expensive strategy, are there any alternatives? Not necessarily, but for contracts there are many free data sources available that use the above strategy. We are talking about the so-called data feeds. I will describe them in the next article.

finanse
obligacje