Mate! You are an absolute godsent in the Yul world (a world where there is no proper documentation on how someone might even deploy Yul). Thank you so so so very much! This is very helpful for my Bachelor's Thesis on Yul. Wish you all the best.
Thank you! And thanks for watching. Yes, for this is part 1 - for part 2 I have a much more complex example here: ua-cam.com/video/F-Wo5D-IX9s/v-deo.html where I code up a full ERC1155 in pure Yul! It has parameter examples to be sure
Great job. But is there a way to inspect the memory during runtime? For example in c or c++ you can debug line by line and inspect that heap/stack of the 32bit data?
Thank you! And thanks for watching. You can try this: `forge test --debug testFunctionName`. Also, and not directly to your question, there's a Yul console.log
I havent used forge yet. I usually use Hardhat. Does forge provide a debugger similar to Remix's? On remix I can inspect the memory/stack and walk through the code (jump over/go into etc) like a traditional debugger @@cryptojesperk
Appreciate it! Yes, that's indeed a bit annoying having to write our own ABI! Perhaps this will be supported in the future, though! Thanks for watching and appreciate the support 🙏
Around 8-10 mins, you mentioned that for gas cost purposes we could use "name_deployed" instead of "runtime". Any documents, links to point me for further digging? Thanks 🙏
@@0xTyfn Some devs will gas golf to minimize the gas cost of function calls by putting as many zeros in the function signature as possible. Here are some good resources on that: - twitter.com/Jeyffre/status/1506286755515088899?s=20 - blog.emn178.cc/en/post/solidity-gas-optimization-function-name/ And some tools to help optimize your function name: - github.com/jeffreyscholz/solidity-zero-finder-rust - emn178.github.io/solidity-optimize-name/
How can we interact with the contract if we have only address of the contract without abi and bytecode. For example i want to call the myFunc from another contract , how to define the interface for that and call it ,as we dont have function name in the yul contract .
Thank you for watching and for your question! So, if you create a Yul contract with functions including "myFunc" you will also need to create a function selector (a "hub"): Something that directs the call to the contract to the right function within your contract. The function selector you implement in Yul should simply take the calldata and pick the first 4 bytes of that calldata. Then, it should compare those 4 bytes to the equivalent signature of your "myFunc()" function, which will change if you have input parameters to it as well. So you don't need an ABI or an interface etc. to call the myFunc() function. You just need to know what the function name is so that you can create the right calldata. The interface is what allows Solidity and the "abi.encode..." functions to do this automatically for you. But you can do it by hand too, it's not that bad. Note that the solidity compiler handles all this for you normally, but in Yul we need to create the function selector in the contract ourselves. Does this make sense? Happy to clarify further.
You can start programming in Yul right now! Go to the link in the description where you can find my code - feel free to copy and modify as you need! Thanks for your question and for watching :-)
The answer to this will vary depending on who you ask and more details about your situation. If I may make some assumptions, I can attempt an answer: Since you indicate you want to be at the top of developers, and I assume you will want to program in Solidity, then: Yes, a thorough understanding of Yul would be necessary. This is because it's often used as the "assembly" block within Solidity (to access more low-level functionality and/or to save gas). And at times, you might want to write entire contracts within Yul (I have seen that less often, though). Overall, it will increase your understanding of Smart contract developments (I recommend you program yourself either an ERC20, ERC115, or similar). You will come to appreciate the abstractions that Solidity offers as well. But that is of course, just my personal view.
Mate! You are an absolute godsent in the Yul world (a world where there is no proper documentation on how someone might even deploy Yul). Thank you so so so very much! This is very helpful for my Bachelor's Thesis on Yul. Wish you all the best.
Thank you very much! I am very happy that you found this useful!
I am very happy to find you channel!
Thank you! I am thrilled to hear it -- thanks for watching and supporting the channel 🙏
Same here❤, so many amazing videos. I have been watching the videos all day
This was excellent. The only thing missing was input parameters to the functions, but we can dig that out of the docs I think.
Thank you! And thanks for watching. Yes, for this is part 1 - for part 2 I have a much more complex example here: ua-cam.com/video/F-Wo5D-IX9s/v-deo.html where I code up a full ERC1155 in pure Yul! It has parameter examples to be sure
Great job. But is there a way to inspect the memory during runtime? For example in c or c++ you can debug line by line and inspect that heap/stack of the 32bit data?
Thank you! And thanks for watching. You can try this: `forge test --debug testFunctionName`. Also, and not directly to your question, there's a Yul console.log
I havent used forge yet. I usually use Hardhat. Does forge provide a debugger similar to Remix's? On remix I can inspect the memory/stack and walk through the code (jump over/go into etc) like a traditional debugger @@cryptojesperk
Really interesting, can the deployed contract written by Yul be able to verify on network explorer, etherscan perhaps
You are doing amazing bro! 👊 The only thing sucks that is writing ABI ourselves 🤦♂🤦♂, but I wasn't surprised that is not possible.
Appreciate it! Yes, that's indeed a bit annoying having to write our own ABI! Perhaps this will be supported in the future, though! Thanks for watching and appreciate the support 🙏
Around 8-10 mins, you mentioned that for gas cost purposes we could use "name_deployed" instead of "runtime". Any documents, links to point me for further digging?
Thanks 🙏
@@0xTyfn Some devs will gas golf to minimize the gas cost of function calls by putting as many zeros in the function signature as possible. Here are some good resources on that:
- twitter.com/Jeyffre/status/1506286755515088899?s=20
- blog.emn178.cc/en/post/solidity-gas-optimization-function-name/
And some tools to help optimize your function name:
- github.com/jeffreyscholz/solidity-zero-finder-rust
- emn178.github.io/solidity-optimize-name/
How can we interact with the contract if we have only address of the contract without abi and bytecode.
For example i want to call the myFunc from another contract , how to define the interface for that and call it ,as we dont have function name in the yul contract .
Thank you for watching and for your question!
So, if you create a Yul contract with functions including "myFunc" you will also need to create a function selector (a "hub"): Something that directs the call to the contract to the right function within your contract. The function selector you implement in Yul should simply take the calldata and pick the first 4 bytes of that calldata. Then, it should compare those 4 bytes to the equivalent signature of your "myFunc()" function, which will change if you have input parameters to it as well.
So you don't need an ABI or an interface etc. to call the myFunc() function. You just need to know what the function name is so that you can create the right calldata. The interface is what allows Solidity and the "abi.encode..." functions to do this automatically for you. But you can do it by hand too, it's not that bad.
Note that the solidity compiler handles all this for you normally, but in Yul we need to create the function selector in the contract ourselves.
Does this make sense? Happy to clarify further.
Done
I would really like to see yul in a production scenario. When is it useful?
You can start programming in Yul right now! Go to the link in the description where you can find my code - feel free to copy and modify as you need! Thanks for your question and for watching :-)
Does hard hat require a Windows PC?
No! You can get started in other operating systems. Thank you for watching 🙏
Sir I have a doubt !
Is it necessary to learn yul to get a high paid BlockChain developer job ?
We need more smart contract hacking videos
Those are exciting! Working on it; thanks for the feedback and for watching!
👍
👍
👍
313
Sir I have a doubt !
Is it necessary to learn yul to get a high paid BlockChain developer job ?
The answer to this will vary depending on who you ask and more details about your situation.
If I may make some assumptions, I can attempt an answer: Since you indicate you want to be at the top of developers, and I assume you will want to program in Solidity, then: Yes, a thorough understanding of Yul would be necessary. This is because it's often used as the "assembly" block within Solidity (to access more low-level functionality and/or to save gas). And at times, you might want to write entire contracts within Yul (I have seen that less often, though). Overall, it will increase your understanding of Smart contract developments (I recommend you program yourself either an ERC20, ERC115, or similar).
You will come to appreciate the abstractions that Solidity offers as well.
But that is of course, just my personal view.