1

I'm writing a Defi project. What I want to do is to set an automatic payment. For example, when a lender asks to lend 10 eth, the money would be automaticly sent to him after a month. I have searched a lot but found nothing. Are there any possible remedy? THANKS!

Alan K
  • 187
  • 2
  • 15
  • Does this answer your question? [run solidity code after every x amount of time](https://stackoverflow.com/questions/68024206/run-solidity-code-after-every-x-amount-of-time) – Petr Hejda Feb 15 '22 at 13:17

2 Answers2

2

You would have to use chainlink keepers for that.

You can put a require statement that will ensure that the eth won't be sent before the 30 days but there is no way to call the function from solidity after 30 days.

Kuly14
  • 496
  • 3
  • 12
2

I'm writing a Defi project. What I want to do is to set an automatic payment. For example, when a lender asks to lend 10 eth, the money would be automaticly sent to him after a month. I have searched a lot but found nothing.

You don't. In Ethereum, transactions are always initiated by the user, or Externally Owned Accounts (EOAs).

You program your smart contract in a way that after certain block.timestamp has passed the user can call claim() function that sends him any payment.

Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435