Alan K
Alan K

Reputation: 197

How to set a timer with solidity?

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!

Upvotes: 1

Views: 2904

Answers (2)

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83666

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.

Upvotes: 4

Kuly14
Kuly14

Reputation: 608

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.

Upvotes: 2

Related Questions