Bitcoin Forum

Alternate cryptocurrencies => Altcoin Discussion => Topic started by: d5000 on August 21, 2018, 05:11:41 PM



Title: Ardor Lightweight Contracts - Trustless Scenario?
Post by: d5000 on August 21, 2018, 05:11:41 PM
Hi,
as some of you may know, Ardor just released its "Lightweight Contracts" feature to Testnet. Basically, they are "smart contracts that not necessarily have to be run by every node". As I understand them, they seem to have some things in common with Lisk's sidechain DAPPs.

As I read in the FAQ (https://medium.com/@lyaffe/lightweight-contracts-faq-30273120da9a), their main drawback is that they are not totally trustless, because you cannot guarantee the "contract owner" really runs the contract.

So for example, if the contract is an "exchange contract" that should give you some token for ARDR (e.g. this one (https://medium.com/@lyaffe/ardor-lightweight-contracts-use-case-71353abb4384)), then if the contract owner doesn't run the contract, you won't get the tokens (and the contract owner could steal your ARDR).

You can run the contract yourself, but AFAIK you can't achieve that the "contract owner" signs the exchange transaction without himself running it - you can only validate that the contract does what he should do according to the source code.

But what if you do the following:
- You first run the contract yourself and calculate the "expected transaction" that should result from it, based on the input from your planned transaction (in this case, the transaction that rewards you with tokens from your ARDR).
- You now issue a phased transaction ("conditional transaction") with the condition of the "expected transaction" - in the exchange case, that you receive the calculated token amount from the contract account.
- If the contract doesn't run or doesn't give you the expected token amount, the transaction expires at some block in the future.

This way, the contract owner can only spend the resulting coins when the contract owner runs the contract. So you are safe from "selective scammers" that run contracts once and then never again.

The contract owner is also safe: He can run the contract first and check that he really is able to produce the desired transaction. If not, then he simply doesn't issue the "expected transaction". So nothing happens (only that we have an useless phased transaction recorded on the blockchain, but I think that is a minor issue).

Is this scenario possible? I haven't read it in the discussions about Lightweight contracts. If not, I think it would be a nice addition, as then Lighweight Contracts would be as trustless (or almost as trustless) as Ethereum Smart Contracts (or even more, as Ethereum contracts can run out of gas).

I hope there are some Ardor folks here that could enlighten me. Otherwise I'll ask this question at Reddit.

Cheers, d5000


Title: Re: Ardor Lightweight Contracts - Trustless Scenario?
Post by: d5000 on August 22, 2018, 08:15:11 PM
Update: I asked the question on Stackexchange: https://bitcoin.stackexchange.com/questions/78506/ardor-lightweight-contracts-almost-trustless-way-with-new-phased-transaction

But if there is someone wanting to respond here, be welcome!

A little addition: Reading the Phased Transaction wiki page it seems that for the scenario a slightly different "phased transaction" type is needed  - one that can require parts of a transaction, like a specific amount of ARDR or tokens that has to be sent to an Ardor address.