1

Imagine I have a poll with specified timestamp for the end. At that point in time votes should be tallied and voters token balances should be adjusted in both directions (increase and decrease).

How to implement such smart-contract that will change users' balances without their interaction? Is it normal ?

2

This can be done by deferred transaction. It's very normal use case, for example, unstaking EOS from CPU and NET bandwidth triggers refund action which is executed in 72 hours. In your case, add the action which handles tallying and adjusting balances and push it with time delay (transaction contains field named by delay_sec) so as to execute transaction after vote process is over.

| improve this answer | |
  • Keep in mind it is possible deferred transactions will not execute as expected. Block.one has mentioned possibly removing them in the future. – netuoso - EOS Titan Jul 25 '19 at 9:18
  • @netuoso Thanks for your comment. Could you let me know where I can find that deferred transaction will be deprecated in the future? – conr2d Jul 26 '19 at 5:15
  • Not really clear documentation in writing but it has been discussed in various channels where Block.One has expressed concerns regarding deferred transactions. eosio.stackexchange.com/a/3255/3333 – netuoso - EOS Titan Jul 26 '19 at 22:40
  • @netuoso I see. A failure on deferred transaction will be noticed by onerror action, so contract can mitigate side effect of deferred transaction by its handler. – conr2d Jul 27 '19 at 5:20

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.