Simple Bytecode Contract | Solidity 0.8

Поділитися
Вставка
  • Опубліковано 21 жов 2024

КОМЕНТАРІ • 37

  • @smartcontractprogrammer
    @smartcontractprogrammer  Рік тому

    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/

  • @devabdee
    @devabdee Рік тому +3

    Amazing, was having some difficulty understanding the MagicNumber Challenge. Now, I'm good to go. Thanks again

    • @kishorevb8331
      @kishorevb8331 Рік тому

      same.
      Are you trying to become a smart contract auditor

  • @The1U22
    @The1U22 Рік тому +2

    My hero helping me with ethernaut now, love it

  • @angrybugs7966
    @angrybugs7966 Рік тому

    Love your videos, also love the reference to the Hitchhiker's Guide to the Galaxy.

  • @jasonpiao8083
    @jasonpiao8083 Рік тому +4

    More low level stuff like this 💯

  • @papahateme
    @papahateme Рік тому +3

    Where does getMeanigOfLife function come from?

    • @smartcontractprogrammer
      @smartcontractprogrammer  Рік тому +3

      the smart contract always returns 42 so it doesn't matter what function you call

    • @МаниМейк
      @МаниМейк Рік тому +4

      @@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)?

    • @MrCoreyTexas
      @MrCoreyTexas 3 місяці тому +1

      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.

  • @kishorevb8331
    @kishorevb8331 Рік тому

    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

  • @kenmeyer100
    @kenmeyer100 Рік тому +1

    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."

  • @0xMorph
    @0xMorph Рік тому

    How did you manage to get the creation code from the opcodes?

    • @pan-galactic-gargleblaster
      @pan-galactic-gargleblaster Рік тому +3

      here's the runtime code but creation code works the same way:
      //0x60 0x2A //push v

    • @0xMorph
      @0xMorph Рік тому +1

      @@pan-galactic-gargleblaster thank you

  • @blaaaabla
    @blaaaabla Рік тому +2

    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 :(

    • @smartcontractprogrammer
      @smartcontractprogrammer  Рік тому +2

      You won't need to understand this, unless you're doing CTF

    • @blaaaabla
      @blaaaabla Рік тому

      @@smartcontractprogrammer thanks bro and thanks for the priceless videos

    • @pan-galactic-gargleblaster
      @pan-galactic-gargleblaster Рік тому +3

      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!

    • @blaaaabla
      @blaaaabla Рік тому +2

      @@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!

    • @ozertayiz
      @ozertayiz Місяць тому

      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.

  • @harpalsinhjadeja2568
    @harpalsinhjadeja2568 Рік тому

    Does this mean that fallback is not something that has a signature?

  • @daniel7007
    @daniel7007 Рік тому

    Fantastic!

  • @mohamedtakieddineabdessela9034

    Thank you 🙏

  • @ken14250
    @ken14250 Рік тому +1

    But why we need to return 32 bytes from memory at 0:41?

    • @smartcontractprogrammer
      @smartcontractprogrammer  Рік тому +2

      42 is stored as uint256
      uint256 needs 32 bytes

    • @ken14250
      @ken14250 Рік тому

      @@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

    • @smartcontractprogrammer
      @smartcontractprogrammer  Рік тому +1

      @@ken14250 Inputs are consumed from top of the stack
      So the first input must be stored last (top of stack)

    • @pan-galactic-gargleblaster
      @pan-galactic-gargleblaster Рік тому

      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

  • @alekseyzhelyabin9017
    @alekseyzhelyabin9017 Рік тому +2

    Magic Number 🪄