@@smartcontractprogrammer is there a way to encode a selector (so I actually can call only function getMeaningOfLife to return 42 and no other function will return this number)?
The name is a joke from the book Hitchiker's Guide to the Galaxy. I found it strange that you can name the function anything and the contract will run regardless. The low level stuff is kind of strange, and you would really need to go through a separate tutorial or playlist just for that. assembly{} is like assembly language, and what he's doing here is more like machine language. I guess this is a good introduction.
I have a doubt: How to convert the op code to byte code. You didn't tell which tool to use to convert the op code to the byte code you came up with I ask this because in the future if I want to write another byte code contract, I would need a way to convert the op code into byte code
Using your sample code, if I try to deploy the Icontract code at the address given in the log, I get "This contract may be abstract, it may not implement an abstract parent's methods completely or it may not invoke an inherited contract's constructor correctly."
guys, am I the only one who struggles with those videos.. I thought I've started getting comfortable with solidity but there are things that I just cannot understand... I am wondering if I should just continue and get back to those later in time or I try to fully understand everything and then continue :(
Hey bud, this is actually a really common feeling that software developers have in general. It's actually a good thing! It means you're figuring out where your hard limits of knowledge are so that you can focus on them. Not to mention, this is also highly specialized content. 99% of the time you will not need to work with low level opcodes and bytecodes in smart contract programming. In fact, it can be *quite* dangerous to do so without extensive experience and auditing. Most large companies won't even be programming their protocols at this level. Dont sweat it!
@@pan-galactic-gargleblaster thanks for the big answer, bro. I'm a software engineer and I don't face this feeling for first time in my life during my career but I'm trying to not miss something and asking if it's a problem to get back to certain topics later on, when I have some experience. Thanks buddy!
I didn't understand this either. I felt bad about it till I remembered Patrick Collins has a 10 hour course about assembly, opcodes and formal verification. ua-cam.com/video/Y3WMkl0AFJk/v-deo.html Hopefully later as I study more, I'll understand these concepts better.
@@smartcontractprogrammer Also why at 2:32, the sequence is 1) PUSH1 0x2a 2) PUSH1 0 3) MSTORE instead of the other way around? Like 1) MSTORE 2) PUSH1 0 3) PUSH1 0x2a
because the mstore() opcode by default uses 32 bytes; its just the way it is. so when you later retrieve that object in memory with the return() opcode you must return the same sized data, which is 32bytes
0:00 - Intro
0:16 - Runtime code
3:20 - Creation code
6:07 - Factory contract
9:11 - Demo
EVM playground
www.evm.codes/playground
Code
solidity-by-example.org/app/simple-bytecode-contract/
Take a course
www.smartcontract.engineer/
Can u explain elliptic curve and how to use it ? , & thank you 🙏
Amazing, was having some difficulty understanding the MagicNumber Challenge. Now, I'm good to go. Thanks again
same.
Are you trying to become a smart contract auditor
My hero helping me with ethernaut now, love it
Ethernaut solutions soon :D
Love your videos, also love the reference to the Hitchhiker's Guide to the Galaxy.
More low level stuff like this 💯
Where does getMeanigOfLife function come from?
the smart contract always returns 42 so it doesn't matter what function you call
@@smartcontractprogrammer is there a way to encode a selector (so I actually can call only function getMeaningOfLife to return 42 and no other function will return this number)?
The name is a joke from the book Hitchiker's Guide to the Galaxy. I found it strange that you can name the function anything and the contract will run regardless. The low level stuff is kind of strange, and you would really need to go through a separate tutorial or playlist just for that. assembly{} is like assembly language, and what he's doing here is more like machine language. I guess this is a good introduction.
I have a doubt:
How to convert the op code to byte code.
You didn't tell which tool to use to convert the op code to the byte code you came up with
I ask this because in the future if I want to write another byte code contract, I would need a way to convert the op code into byte code
ethervm.io/
Using your sample code, if I try to deploy the Icontract code at the address given in the log, I get "This contract may be abstract, it may not implement an abstract parent's methods completely or it may not invoke an inherited contract's constructor correctly."
don't deploy, load the interface at the address
@@smartcontractprogrammer Thank you!
How did you manage to get the creation code from the opcodes?
here's the runtime code but creation code works the same way:
//0x60 0x2A //push v
@@pan-galactic-gargleblaster thank you
guys, am I the only one who struggles with those videos.. I thought I've started getting comfortable with solidity but there are things that I just cannot understand... I am wondering if I should just continue and get back to those later in time or I try to fully understand everything and then continue :(
You won't need to understand this, unless you're doing CTF
@@smartcontractprogrammer thanks bro and thanks for the priceless videos
Hey bud, this is actually a really common feeling that software developers have in general. It's actually a good thing! It means you're figuring out where your hard limits of knowledge are so that you can focus on them.
Not to mention, this is also highly specialized content. 99% of the time you will not need to work with low level opcodes and bytecodes in smart contract programming. In fact, it can be *quite* dangerous to do so without extensive experience and auditing. Most large companies won't even be programming their protocols at this level. Dont sweat it!
@@pan-galactic-gargleblaster thanks for the big answer, bro. I'm a software engineer and I don't face this feeling for first time in my life during my career but I'm trying to not miss something and asking if it's a problem to get back to certain topics later on, when I have some experience. Thanks buddy!
I didn't understand this either. I felt bad about it till I remembered Patrick Collins has a 10 hour course about assembly, opcodes and formal verification.
ua-cam.com/video/Y3WMkl0AFJk/v-deo.html
Hopefully later as I study more, I'll understand these concepts better.
Does this mean that fallback is not something that has a signature?
yes I think fallback is a function without a signature.
Fantastic!
Thank you 🙏
But why we need to return 32 bytes from memory at 0:41?
42 is stored as uint256
uint256 needs 32 bytes
@@smartcontractprogrammer Also why at 2:32, the sequence is 1) PUSH1 0x2a 2) PUSH1 0 3) MSTORE instead of the other way around? Like 1) MSTORE 2) PUSH1 0 3) PUSH1 0x2a
@@ken14250 Inputs are consumed from top of the stack
So the first input must be stored last (top of stack)
because the mstore() opcode by default uses 32 bytes; its just the way it is.
so when you later retrieve that object in memory with the return() opcode you must return the same sized data, which is 32bytes
Magic Number 🪄