[Solved] Can Contract create another Contract/Oracle?

Hi there,

I am trying to implement an app in Sophia, where one Contract needs to create other multiple Contracts? Is it possible in the current Aethernity/Sophia version? Same question for Oracle: can Contract create an Oracle on its own?

P.S. Solidity example - Solidity, create contract from contract - Ethereum Stack Exchange

Thanks!

No, a contract cannot (at the moment) create another contract.

Yes, a contract can register as an oracle (there is no concept of creating an oracle, you register an existing account as an oracle). See protocol/sophia.md at master · aeternity/protocol · GitHub

2 Likes

Thanks for the answer.

I am now trying to understand, whether my Contract, which also registered as an Oracle, can somehow be subscribed for open questions on the chain. I do not really understand how Oracle.get_question function supposed to work, since it requires me as an Oracle to know the query. How can I get the query then? I am completely lost at this point.

No, there is no on-chain subscription mechanism accessible from within the contract. That would open up for all sorts of weird behavior. You could certainly envision having an external service scanning the chain for oracle queries and then triggering the contract.

So, for a contract-oracle you need to feed it the QueryId of the question to it in a contract call, and then the contract-oracle can get the question and prepare and post an answer.

2 Likes

thanks @hanssv.chain, I think I slowly understand how Oracles can be implemented.

I wish I found this tutorial earlier: https://dev.aepps.com/tutorials/sophia-oracle-introduction.html My key thing for understanding was a function greet_oracle which one can use to initiate a query.

2 Likes

hannsv, are there any updates on contracts creating another contract? When is this feature gonna be implemented?

I have no updates on that.

All I know is that it is not an immediate priority at the moment, so I am afraid I have no time plan to share.

1 Like