13 likes
·
351 reads
9 comments
Great work, as usual. I have a question, what if the redeemer misses a cycle. Would he be able to redeem 2 (or whatever he missed + 1 ) tokens at once? I assume Payment tx with amount equal to = (cycle_number - current_balance) * payment_amount would cover that scenario.
Thanks Eldar!
In this particular design, only one token can be redeemed at a time (there is a check in the claim_payment() method to make sure the asset amount is 1).
The would stop someone claiming more than one payment at a time.
They also can't catch up on old payments one by one, because I doubt that would be possible in most real life subscription scenarios either.
The payment receiver does have the full cycle interval time to claim a payment - which could be an entire month, for example.
Thanks for the reply, Alex.
If I miss a payment, wouldn't I be able to catch up one by one? It would return 0 until I have caught up to hit the next_balanace == cycle_number, and then I'd get paid. Or am I missing something?
Oh, I forgot that returning 0 means Reject ). Eldar Ahmadov
You would be able to keep depositing tokens until next_balance == cycle_number, but you'd only receive a payment for the last one (when next_balance == cycle_number).
So for example if it's currently cycle 3 and you haven't claimed any payments yet, you could either:
- Transfer 2 tokens to the contract without calling the claim_payment() method, and then call the claim_payment method sending an additional token and receive one payment.
or
- Call the claim_payment() method three times, transferring a single token each time. You would only receive a payment for the last one (token/cycle 3).
Got it, thanks again!
You should definitely consider making courses, you have an excellent way of explaining. I'd happily support that! I'm learning python itself in parallel (dotnet developer here) so your posts are a HUGE help!
Keep those posts coming!
Can you explain how to deploy this contract on Ethereum?
Edited by slope game 1 day ago
You would have to rewrite it in Solidity/equivalent.