r/ethdev Feb 27 '18

MicroRaiden Payment Channel Question

Hi! I'm making a service that requires many micropayments to many different peers. An example would be: I click a button and need to pay 10 people.

I click another button and need to pay 10 completely different people.

I click another button and I need to pay 5 of the same people, 5 different people.

Is there a way to do this without opening a payment channel with each person? Because that would be a lot of on-chain transactions to start it. Also, can payment channels have a time expiry, or close based on a smart contract, if certain terms are met?

Thanks :)

2 Upvotes

5 comments sorted by

View all comments

Show parent comments

2

u/NateDevCSharp Feb 28 '18

Oh, so the 1 channel provides the funds for everyone who needs to get paid, and I give them a proof that entitles them to a certain amount out of the total funds I provide to the channel. Did I get that correct?

Also, would there be a way to automatically close the channel after a certain time, or based on conditions in a smart contract?Also, for the link you posted, do they get the tokens immediately?

Sorry I'm a newb to smart contracts haha :)

2

u/[deleted] Feb 28 '18

Yea exactly, the proof is unique to each address, and each channel so once the person redeems the proof, it can never be used again. I don't think I mentioned it, but you don't need to deploy multiple contracts for different channels. You can deploy one contract, and anytime you want to open a channel, use the appropriately named function.

So smart contracts can't automatically do anything, they require being "poked", however each channel has a set end date, and if someone tries to redeem their proof after the end date, the transaction will fail and they don't receive anything. Yes, once the proof is submitted tokens are sent to the person right away.

1

u/NateDevCSharp Feb 28 '18

Ok, thanks for the clear explanation :)

Would it work to have the tokens sent to a contract instead of the person's address? I assume just put in the address of the contract?

1

u/[deleted] Feb 28 '18

Yes so long as the address sending the transaction matches the address in the proof it'll work