Thanks for your great tutorials! I have a question. Why use `revert` and `if` at error case, instead of require? Does have any gas efficient? or other benefits?
As far as I know, require is more gas efficient than writing if + revert. However writing custom Errors is more gas efficient than the require statement. The most efficient solution would be to have a require statement with custom error, but this is not yet supported in solidity (hopefully in future). In this case it shouldnt matter much i guess because using custom errors are pretty convenient.
On line 103, why do you have to cast a string into bytes to check the length? From all of my previous experience I'd think a string datatype would support a length operator. If not, solidity has pretty weird exceptions.
I am confused this for 24 hours. For example, if I decide to donate 1 ETH to you today(6/19), and I set the _timestamp= 1 day, so what does that mean? then, you set min=3 days and max=10days, so what does that mean? then you set the grace_period = 30 days, so what does that mean? we already have current+min and cruuent+max, why still need grace_period? in the other word, if we have grace_period, then we don't need current+min and current+max? also, is the _timestamp really necessary?
@@mustaphaidris1584 Thanks for your reply! I still don't get the answer. It would very much appreciated if you can use my donate case to explain those the relationship of block.timestamp, min delay, max delay and grace period!
MIN and MAX dictate the range of time you can *set* for the transaction to be executable. Grace period is the amount of time you have after the time that was set to execute the transaction
Amazing content, and I always refer to your work. Is it possible for others to view that a timelocked transaction was queued up? I know that DAOs and other web3 projects use Timelocks for certain admin controls, and this is something that others can view and withdraw from the protocol if it's malicious, for example? Is that a different Timelock implementation (OpenZeppelin, I think)?
Thnx for this very helpful tutorial. Why do we need to check whether _func parameter is empty string or not, anyways its going to call receive if we just send the _data with call?
@@smartcontractprogrammer Was there ever a time that you weren't good at this...so good it seems you were born with it...thanks for being available ... Honestly wouldn't mind the vesting video...
Could you continue this implementation focusing in atomic swaps? I wonder how can we use it to be able to transfer ERC20 tokens between EVM-based blockchains. Thank you very much about such rich content!
Do we get something for offchaining txs storing only its hash aside storage gas fees economy? And does it make significant difference? Am I right that we can get "cashback" when deleting executed txs from contract storage?
I guess with custom errors you can pass in arguments appropriate to the situation, whereas when you use require, generally it outputs a fixed string. I've tried to do string manipulation in Solidiy, and let me tell you, it is really hairy & ugly. I haven't tested, but I'm guessing it would use less gas to use custom errors vs. trying some kind of string manipulation with require().
No, flashloans need to be repaid in the same transaction, so no delays are allowed. When doing time locks, you are operating with two or more different transactions.
@@daniel.contreras you could still queue a flashloan into a timelock, and have it execute (and pay back) in the same future block. Not sure if that is what the question is about though.
1:31 - queue
9:37 - execute
17:53 - cancel
19:19 - demo
Thank you for continuing to deliver great tutorials
Best solidity videos in UA-cam .......thanks man...
best channel on youtube
high quality content
Thanks for your great tutorials!
I have a question.
Why use `revert` and `if` at error case, instead of require? Does have any gas efficient? or other benefits?
As far as I know, require is more gas efficient than writing if + revert. However writing custom Errors is more gas efficient than the require statement. The most efficient solution would be to have a require statement with custom error, but this is not yet supported in solidity (hopefully in future). In this case it shouldnt matter much i guess because using custom errors are pretty convenient.
@@illegalskillsexception9826 great! thanks
Awesome video, thank you!
This is amazing! Thanks!
On line 103, why do you have to cast a string into bytes to check the length? From all of my previous experience I'd think a string datatype would support a length operator. If not, solidity has pretty weird exceptions.
please help , this code is not running in remix ide
I am confused this for 24 hours. For example, if I decide to donate 1 ETH to you today(6/19), and I set the _timestamp= 1 day, so what does that mean? then, you set min=3 days and max=10days, so what does that mean? then you set the grace_period = 30 days, so what does that mean? we already have current+min and cruuent+max, why still need grace_period? in the other word, if we have grace_period, then we don't need current+min and current+max? also, is the _timestamp really necessary?
Grace period is just a period that is given to you before the transaction expires
@@mustaphaidris1584 Thanks for your reply! I still don't get the answer. It would very much appreciated if you can use my donate case to explain those the relationship of block.timestamp, min delay, max delay and grace period!
MIN and MAX dictate the range of time you can *set* for the transaction to be executable. Grace period is the amount of time you have after the time that was set to execute the transaction
@@phlipside Thanks a lot! It’s really helpful!
Amazing content, and I always refer to your work.
Is it possible for others to view that a timelocked transaction was queued up? I know that DAOs and other web3 projects use Timelocks for certain admin controls, and this is something that others can view and withdraw from the protocol if it's malicious, for example? Is that a different Timelock implementation (OpenZeppelin, I think)?
yes from the event logs
Thnx for this very helpful tutorial. Why do we need to check whether _func parameter is empty string or not, anyways its going to call receive if we just send the _data with call?
9:33 how you quickly re-align the code in Remix?
highlight + tab or highlight + shift + tab
@@smartcontractprogrammer awesome
Isn't this what is used for vesting of tokens???
No. I can make a video about vesting
@@smartcontractprogrammer Was there ever a time that you weren't good at this...so good it seems you were born with it...thanks for being available ... Honestly wouldn't mind the vesting video...
Could you continue this implementation focusing in atomic swaps? I wonder how can we use it to be able to transfer ERC20 tokens between EVM-based blockchains. Thank you very much about such rich content!
And there is no way to keep repeating on certain interval right ? for that we may have to use Chainlink Keepers ?
Yes. Chainlink keeper or write a bot or something
Do we get something for offchaining txs storing only its hash aside storage gas fees economy? And does it make significant difference? Am I right that we can get "cashback" when deleting executed txs from contract storage?
yes you can save gas by simply storing the hash inside the contract
yes htere is a refund for deleting data
Hey, why passing all the params twice in queue and execute, instead of string the tx with a running tx_id, and just using it in execute(tx_id)?
expensive to store transaction data
Is there any reason you use "revert" with custom defined errors, rather then "require"?
Just to mix things up. Also can't use require with custom errors.
I guess with custom errors you can pass in arguments appropriate to the situation, whereas when you use require, generally it outputs a fixed string. I've tried to do string manipulation in Solidiy, and let me tell you, it is really hairy & ugly. I haven't tested, but I'm guessing it would use less gas to use custom errors vs. trying some kind of string manipulation with require().
Where can I find the full code?
solidity-by-example.org/app/time-lock/
DOES THIS DELAY ALL BUYS AND SELLS?
no
thanks!!!!!!
Is it possible to time lock a flash loan?
No, flashloans need to be repaid in the same transaction, so no delays are allowed. When doing time locks, you are operating with two or more different transactions.
@@daniel.contreras you could still queue a flashloan into a timelock, and have it execute (and pay back) in the same future block. Not sure if that is what the question is about though.