21

Is it possible to use Stellar to create an address that will automatically distribute payments to two different parties? For example, if 10 XLM is received to address x, 8 XLM are instantly distributed to address a, and 2 XLM are distributed to address b.

This would be an awesome use case for something like: by purchasing a song, 80% goes to the artist and 20% goes to the label. All verified on the Stellar network.

I'm wondering if there is a decentralized "Smart Contract" approach to this, as opposed to an off-chain script (which would need the private key to address x) doing the distribution.

I've looked through the documentation, and think this perhaps could be solved with a Pre-Authoried Transaction. If a Pre-Authorized transaction is in fact the correct approach: do you need to pay a fee to the Stellar Network to set up an account with a Pre-Authorized Transaction?

I'm not sure if this is the correct approach though. I'd love to hear suggestions for alternatives.

15

I can't think of an easy way to do this right now. If someone has a proposal for an extension to allow things like this please put it here: https://github.com/stellar/stellar-protocol

2

First of all, you can't execute code programmatically (like Ethereum Smart Contract) in Stellar, but you can programmatically create pre-defined transactions getting variables from in-chain data.

Let me explain what would be my approach to your scenario and I'd like to have feedbacks:

  • Setup a new "data account" with enough XLM to host a couple of key:value in the data layer (https://www.stellar.org/developers/guides/concepts/list-of-operations.html#manage-data)
  • Remove platform (we assume that we are hosting a platform/API to manage this royalty payments) trust and give trust from the artist account to the data account (so only artist can manage it)
  • Now let artist tell you how to split royalties (80% to her and 20% to label) and let her setup two key:value { artist_address: 80, label_address: 20 } in the "data account"
  • You are almost done, now each time someone buys artist's song create a tx with 2 payment operations getting the address/percentage (and so amounts) from the "data account" you created before and you are done

What's happened? You have created a special account in-chain assigning it the data the artist wants and removing your trust, so basically only the artist can handle that data. Finally creating tx based on the data from that account let you compose the specific amounts wanted by the artist and artist can always verify they are those she wanted.

This is a very basic set of operations, you should also include a merge operation to get back XLM balance when an artist un-publish her song, and probably set the association between "artist account" and "data account" in the artist account data layer, but basically it should work as expected.

Bonus: You could also use pre-authorized tx when you (as platform) create the payment tx for the artist and let the artist submit it (after verifying it). Check this to have an idea of how it could work How to determine sequence no for pre-authorised transaction with time bound validity without blocking other new possible transactions

0

I'm just creating a timed-payment service (https://test.artspirit.com still beta). I'm working quite heavy with Pre-Authorized Transactions.

You need a bit more than just Pre-Authorized Transactions, but I think there is a way.

  • Pre-authorized transactions won't help you, since you have to know the amounts for that to work. The easiest way would be to just make multiple recipients in the original payment. – Johan Stén Sep 2 '18 at 4:04
0

@michelem: nice solution. the only thing is: the paying account needs to know about the data-account and get the %-values. if that is possible then its fine.

if you don't have access on the paying process and just see the account where the payment comes in then my solution would be:

define a number of pre-authorized payments with a fixed amount. lets say if I expect 100 USD per month. If 100 USD is reached I would use two preauth-transactions one with 20 USD and one 80 USD and pay this out. this should also work. of course you need a third party to check the account and submit if 100 USD is reached.

  • data is in-chain so in the public ledger, you only need to know what the account is holding it – michelem Sep 4 '18 at 5:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.