My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Alexander Codes

13 likes

·

263 reads

6 comments

Eldar Ahmadov
Eldar Ahmadov
Apr 18, 2024

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.

1
·
·5 replies
Alexander Codes
Alexander Codes
Author
·Apr 19, 2024

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.

·
Eldar Ahmadov
Eldar Ahmadov
Apr 19, 2024

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?

Alexander Codes

·
Eldar Ahmadov
Eldar Ahmadov
Apr 19, 2024

Oh, I forgot that returning 0 means Reject ). Eldar Ahmadov

·
Alexander Codes
Alexander Codes
Author
·Apr 19, 2024

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:

  1. 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

  1. 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).
·
Eldar Ahmadov
Eldar Ahmadov
Apr 19, 2024

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!

Alexander Codes

1
·