I'm working on a smart contract that will allow users to pay for monthly subscriptions like Netflix, Amazon, etc. The smart contract is designed in a way that in order for a user to pay his monthly subscription, he has to approve the smart contract to transfer X amount of tokens on his behalf (ERC20 rules) I was curious if there is a way to make the monthly payment automatically, which means that the user doesn't have to interact with the smart contract each month to pay for his subscription but the smart contract withdraws each month X amount of tokens from the user's wallet. I don't think this will be possible because of the blockchain limitations and the security aspects of it. But I’d like to learn from you if there is any other solution or approch

1 Answer 1


For any transaction on the blockchain, someone must start the execution. So in order for tokens to be transferred from users every month, somebody, doesn't necessarily have to be the user, must start the onchain transaction to move tokens. Smart contracts do not automatically do actions without someone or something calling into them.

That said, if the users were paying in a specific token that you programmed, you could write conditional logic where the user's balance is based on a condition related to time and subscriptions. This logic would need to be entirely passive, aka you cannot make any state changes to a contract without a transaction happening. This includes external token contracts, where the state is someone's balance. This is pretty advanced, and would need some deep thought into the condition's being checked in a user's balanceOf function, and gas considerations for when the balanceOf function is needed to be called on chain (for example, in a transfer verifying if a user has tokens to give away). In theory I think you might be able to make some system where user's and providers balances are passively updated based on balanceOf logic depending on the timestamp, but keep in mind it must be efficient and scalable. Also, it can be dangerous to mess with ERC20 internal logic functions, so take care if you decide to do it!

You could also consider the subscription provider makes the transaction to collect the money, or an address controlled by the protocol team makes a call to collect all subscriptions at the end of a month. Keep in mind the gas costs for this will be significant though, since you are not actually removing the cost of the transaction, just changing who pays for it. So the gas for many users will need to be paid all at once.

  • Thanks for sharing your thoughts Bruce!
    – David Jay
    Nov 8, 2022 at 7:26

Your Answer

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

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