November 26, 2019

Stellar smart contracts Part 2: constraints and use cases

Last time, we talked about how smart contracts work on Stellar. We saw that they are much easier to master than in Ethereum, and it only costs a few cents to deploy a contract. We also mentioned that you don’t need to write the whole code from scratch — you can use different transactions and constraints to build your contract in any coding language you prefer.

In this post, we’ll describe these constraints and see how you can use SSCs in real life. Here are the most important constraints:

Sequence — here you can define the correct order for transactions.

Time bounds — identifying the period within which a transaction is valid. For example, the duration of the ICO.

Batching/Atomicity — you can set your transactions in such a way that some of them will all have to succeed or fail together. You can also set the conditions: what does it mean to fail, for example?

Multisig — you can decide how many users (and even which users precisely) have to sign a transaction.

SSCs may not be Turing-complete, but they can still satisfy the requirements of most startups at the early stage. True, you can’t build a complex logic with them. But if you are creating something like a marketplace, a loyalty program, or just want to fund some project of yours, Stellar is perfect. Here are two use cases:

1) Shopping in online marketplaces

There’s a big problem with selling physical goods online for crypto. They are not like digital goods — they take a few days to be delivered. And sometimes they don’t get delivered at all, or the color or size is wrong, or the item arrives damaged, or the customer decides he doesn’t like it… In all these cases, you’d normally request a refund, right? Only there is no functional system for refunds in crypto. All transactions are final. So how can we prevent the seller from pocketing the money?

Escrow with multisig is a good answer. The customer’s money isn’t transferred to the seller — it’s placed in escrow instead. There can be a third party acting as the escrow agent — the administration of the marketplace, for example. The important thing is that with Stellar you can easily design a contract that requires multiple signatures to release money. Or you can create a contract that automatically releases money after a certain period.

2) Startup crowdfunding

There are many platforms that help blockchain startups raise money (KickICO, etc.). But the control over the process is firmly in the hands of the administration of these platforms. The service provider charges a hefty fee for “ensuring security” and so forth. It would be good to be able to fund your project via a smart contract alone, but without the risks of the ICO.

With Stellar, you can easily do that. You can issue and sell a new asset, as we have seen the last time. And you can also formulate your contract in such a way that it will automatically return the investments to all the participants if the project doesn’t meed its soft cap.

Actually, building a crowdfunding platform like KickStarter on Stellar is much easier and cost-efficient than on Ethereum. Projects wouldn’t need to pay for someone to create and launch their new asset. They wouldn’t need the platform to act as a guarantor. The costs would be very small overall.

Next time, we’ll discuss how to manage multiple accounts in your XLM wallet — and even how to merge them.

https://xlmwallet.co/

Web site - https://xlmwallet.co/

Medium - https://medium.com/@XLMwalletCo

Teletype - https://teletype.in/@XLMwalletCo

Twitter - https://twitter.com/XLMwalletCo

Reddit - https://www.reddit.com/user/Stellar__wallet