Trustless Oracle Contracts

It is known that data is whether available during contract execution, or available via oracles, and in the latter case some trust is involved.

However, in some cases we can commit to data via contracts, and then access the data when it is not available in execution context anymore. We can say about trustless oracle contracts here.

One good example here, and already used in practice, is certification of spent boxes , discovered by @anon_real and used in Auction House for royalties , ErgoScript Design patterns - #23 by kushti .

Another example (not implemented yet) is a contract which is storing commitments to all the block headers in the Ergo blockchain. In execution context, last 10 headers are available. Thus we can have a contract, with trusted setup initially, which is about all the headers to the moment stored under AVL tree, and the contract allows to add a header to the tree if it contains in the execution context (so last 10 headers). Then this contract can be used as an oracle, and can be used e.g. to prove that there was some box in the UTXO set even if it spent now.

Also, we can do the same for storing e.g. Bitcoin headers under AVL tree, we need to implement Bitcoin SPV client as a contract though (but there could be some techniques to execute this contract optimistically in a lightweight way I guess).