2

I am writing a smart contract of a charity.It pay all the money to it's subscribers in every week. I am puzzled in such point that who will pay the transaction cost of transfer?

When I am calculating splitAmount=(contractBalance/totalSubscriber) , here I am giving all my contract balance to these subscribers so I have balance remain for pay the transactional fees. What will happend here.How can I handled this situations?

2
  • It would be helpful to include the relevant portions of your smart contract. I am also not sure what you mean with "automatically transfer"? Every change in Chain has to be triggered by a transaction, which always requires an external account as the sender.
    – ivicaa
    Nov 25, 2018 at 12:52
  • 1
    Please check this : ethereum.stackexchange.com/a/145/25049 Nov 25, 2018 at 13:02

1 Answer 1

1

Automatic transfers are not secure, you should opt in for an withdrawal method where users withdraw their money and pay for the gas.

You can start here to have an idea : https://solidity.readthedocs.io/en/v0.4.24/common-patterns.html#withdrawal-from-contracts .

I've been stugglin with this for a while too. I hope someone that knows much more than me can provide a better answer and examples, I just told you a few things I learnt so far.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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