0

I want to create a BuyMeACoffee contract where the tippers can withdraw the amount they tipped before 24hours of transactions, but I also want the owner to be able to access (or withdraw) these tokens after those 24hours of time.

What I thought of is to build a struct with the timestamp and tippers address and make them call the function before the 24 hours using the timestamp.

But I am not able to get how shall I implement for the owner, that we can only access those tokens after a period of time.

For Example=> If the owner already got tips of 100 dollars before and got another one of 20 dollars today then he should be able to withdraw 100 dollars only today and 120 dollars tomorrow.

I hope I made myself clear regarding my query.

1 Answer 1

0

I would think that you could have a tx to 'give the tip' and when the tip is given you could timestamp it when saved into the struct.

Then in the function that 'claims' the tip, you would have a modifier that checks the timestamp 'now' relative to the one in the struct tagged to the address.

I think you would have to have an entry per 'tip', or a robust struct that could have an 'array' of 'tip' objects inside of that key. That key would be in another struct that represents the 'user' or 'address'.

Hope that helps!

PS. see this, I have used this library to help me build robust iterable data structs

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.