Smart contract tutorial

Hi,

Lately I read a blog about blockchain technology. In that blog somebody gave an example what a smart contract could do. The example was:
If somebody joins a run for charity, a sponsor (company) is willing to pay money only if the runner completes this run and if his commercial on youtube is watched 1000 times.

Is this possible using NEM in a safe way? And if so, it would be great to work this out in a tutorial so new nemmers will get a more practical feeling of what NEM is capable of. Maybe I could write the tutorial if somebody could point me in the right direction?

Regards,

Raymond

Yes…ish.
You can most certainly use multisig to lock the money in an account until it is verified that all conditionas have been met. However the verification of said conditions will need to happen off-chain. In this particular example even a full-blown smart-contract system like ethereums wouldn’t do much better though, as data outside of the blockchain (i.e. did he finish and did the commerical get the views) are needed.

So what you’d probably end-up doing is put the money in a multi-sig account where the runner, the sponsor and a third, unbiased entity hold keys and at least 2 of the 3 co-signatories need to sign in order to pay out the money.
If the runner is successfull then the third-party will sign his tx of paying out the money to him.
If the conditions are not met then the third-party will sign the tx to pay the money back to the sponsor.

Whether that third-party is a human or code doesn’t matter. It needs information that is outside of the blockchain anyways.

Hello !

I would suggest you have a look at PacNEM - It implements a simplified version of Pay per View Advertising, sending mosaics after 3 ad views. This would apply to your commercial views features.

Also, if you wish you can use Mosaics to store State Data about your Runner.

  • Your runner starts the run: he receives a run:start mosaic.
  • Your runner crosses the end line of the run: he receives a run:done mosaic.
  • Add more features by adding “checkpoints”: runner receives run:checkpoint mosaics for each kilometer, for example.

I hope this helps!

And I would recommend you have a read of: https://blog.nem.io/pacnem

Cheers

2 Likes