Learn Solidity (0.5) - Delegatecall

Поделиться
HTML-код
  • Опубликовано: 6 окт 2024

Комментарии • 34

  • @DaBossLewis
    @DaBossLewis 4 года назад +3

    Great video. You explained it very well. I have read about delegate call a few times, but this video really helped make the knowledge useful. Thanks :)

  • @coinymous
    @coinymous 2 года назад +1

    awesome , best channel for solidity I've seen 😍

  • @salem232
    @salem232 4 года назад +3

    😍👍 super video explaining the content!!! Classic diagram with animation made very easy to grasp !! Thank you!!

  • @benparish6772
    @benparish6772 3 года назад +2

    Great explanation. Easy to understand.

  • @aryastark4064
    @aryastark4064 3 года назад

    thanks for explaining all these very easily . that solidity document was driving me crazy

  • @vanvantsyan
    @vanvantsyan 3 месяца назад

    awesome explanation!

  • @SingleWingAcademy
    @SingleWingAcademy 2 года назад

    Great video. Helped me beat the level on ethernaut lol

  • @edwassermann8368
    @edwassermann8368 2 года назад

    excellent. that was an important puzzle piece for me.

  • @apoorvlathey5421
    @apoorvlathey5421 4 года назад +1

    This video was so helpful. Thanks!

  • @TjSpoonManJacques
    @TjSpoonManJacques 3 года назад

    Great video - I really appreciate you!

  • @kb8341
    @kb8341 4 года назад +1

    Best explanation ever!

  • @startat3098
    @startat3098 3 года назад

    You are the best as always!

  • @rameezshuhaib6456
    @rameezshuhaib6456 3 года назад +2

    Thanks for this awesome video! This was something I was searching for :)
    But I have a doubt Wouldn’t this have any security issue? Since I can run any custom code and update the actual storage. Is there a way to allow only trusted upgraded contracts created by the owner?

    • @smartcontractprogrammer
      @smartcontractprogrammer  3 года назад +1

      Yes there are hacks done exploiting delegatecall. You will have to write authorization code for trusted upgrade

    • @gabrielnastari8513
      @gabrielnastari8513 3 года назад +2

      address admin_address;
      // only run in deploy
      constructor(){
      admin_address = admin_address;
      }
      function something(){
      require( msg.sender == admin_address, "Dont authorized");
      delegatecall()
      }

    • @smartcontractprogrammer
      @smartcontractprogrammer  3 года назад +2

      @@gabrielnastari8513
      constructor() { admin_address = msg.sender ; }

    • @gabrielnastari8513
      @gabrielnastari8513 3 года назад +1

      @@smartcontractprogrammer right, lol! i wrote twice ! You correct admin_address =msg.sender !

    • @gabrielnastari8513
      @gabrielnastari8513 3 года назад +1

      @@smartcontractprogrammer Thanks , you are awesome man!

  • @japaroski
    @japaroski 2 года назад

    You are the best!

  • @كيفتصنعللاطفال
    @كيفتصنعللاطفال 3 года назад +1

    Thanks for the great tutorial. I deployed your example using Javascript VM. It works.
    I deployed it using Ropsten testnet. It does not work.
    Can you please help me to run it on a testnet.
    Thank you

    • @smartcontractprogrammer
      @smartcontractprogrammer  3 года назад

      Deploy all relevant contracts on Ropsten. Make sure the addresses are correct

    • @كيفتصنعللاطفال
      @كيفتصنعللاطفال 3 года назад

      @@smartcontractprogrammer I ran the same code on Ropsten again and I am sure that the addresses are correct. It still does not work. Have you tried it yourself?
      I even modified your code as below. I give the input 2. When I run it on JavaScript VM the result is 8. When I run it on Ropsten the result is 4. Different results for the same code. Please try the code below yourself
      /*first file*/
      pragma solidity ^0.7.6;
      abstract contract B {
      function setVars(uint _num) public payable returns(uint) {}
      }
      contract A {
      uint public num=1;
      uint x=1;
      function setVars(address _contract, uint _num) public payable {
      // A's storage is set, B is not modified.

      num = B(_contract).setVars(_num);
      (bool success, bytes memory data) = _contract.delegatecall(abi.encodeWithSignature("setVars(uint256)", num));
      }
      }
      /*second file*/
      pragma solidity ^0.7.6;
      contract B {
      // NOTE: storage layout must be the same as contract A
      uint public num;
      address public sender;
      uint public value;
      uint x=1;
      function setVars(uint _num) public payable returns(uint) {
      num = 2*_num;
      sender = msg.sender;
      value = msg.value;
      return num;
      }
      }
      Thank you and I appreciate your kind help to me

    • @كيفتصنعللاطفال
      @كيفتصنعللاطفال 3 года назад

      can you help me please :)

  • @福瑞黃
    @福瑞黃 2 года назад

    Very Good and no one can do better than you ! Well, If I don't other contracts to call or delegatecall the functions of my contract, what should I do? Please advise, Thanks!

  • @MrCoreyTexas
    @MrCoreyTexas 3 месяца назад

    I'm wondering, when was delegatecall introduced into the EVM? Was it there from the beginning, or did they add it later when they figured out that they'd need a way to upgrade contracts?

  • @rattle_
    @rattle_ 4 года назад +1

    So the first contract works like a proxy.

  • @jordixboy
    @jordixboy 3 года назад

    Good explanation, what happens if you do a delegate call, the contract calls the second contract, but the first contract doesnt have that state variables defined, I assume the call would fail?

  • @malawad
    @malawad 3 года назад

    super helpful , thanks a lot

  • @jagadeeshgajula4014
    @jagadeeshgajula4014 3 года назад

    very cool

  • @MrCoreyTexas
    @MrCoreyTexas 3 месяца назад

    very interesting, programming was getting kind of dull for me over many decades (nothing new under the sun as it were) until i discovered crypto currency

  • @neeble9575
    @neeble9575 3 года назад

    You are the best!