Fallback | Solidity 0.8

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • Fallback is a special function that is executed when a non-existing function is called. It's mainly used to enable the contract to receive ETH.
    #Solidity #SmartContract #Ethereum #スマートコントラクト
    Remix
    remix.ethereum...
    Code
    solidity-by-ex...
    Take a course
    www.smartcontr...
    Follow
    / programmersmart
    / discord
    t.me/smartcont...
    smartcontractp...

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

  • @tetuaoro
    @tetuaoro 2 года назад +7

    The best profesor for blockchain ever. Thanks a lot for this video.

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

    You have a mania or a gift 🙇🏽 of making complicated and complex things seems so simple, easy to understand, with succinct explanation and examples.

  • @sumimudgil2019
    @sumimudgil2019 2 года назад +4

    Hi! Just wanted to say that this is the most helpful solidity youtube series so far - thanks for making these!

  • @Hi_Chew
    @Hi_Chew 2 года назад +4

    Great explanation!!! The most efficient 5 minutes I've spent.

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

    The best explaination I could find, thanks a lot!

  • @Bruhne
    @Bruhne Год назад

    Got it! I just purchased the physical book Solidity Programming Essentials; and so where ever I am with you, I go into the book to learn more on said subject. I dive into your material very early in the mornings, and I delve into the book later in the days.

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

    Perfect video

  • @sdfsfsfd437
    @sdfsfsfd437 2 года назад +4

    great explanation, I learn with your videos! many thanks!

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

    Apparently the fallback function is very useful for the upgradeable contracts pattern as well. Btw, many thanks to this video, is very helpful indeed.

  • @engenglish610
    @engenglish610 Год назад +1

    Useful content 🎉

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

    Best example for fallback function and gave clear difference for fallback and receive

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

    best solidity tutorials on youtube! Thanks!

  • @meka4996
    @meka4996 Год назад

    Excellent! Thanks

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

    Man, I'm happy that I notice this channel.
    But feel guilty that I didn't know as early as possible!

    • @user-qf2fm4js1z
      @user-qf2fm4js1z 2 года назад

      比特彭您好, 請問您是台灣的彭彭老師(Javascript及Python)嗎? 您來自台灣或大陸? 我來自台灣.

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

    Obviously, a genius is behind all that simplicity

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

    Great tutorial. Thank you.

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

    thank you so much ... i learn more knowledge from your channel

  • @user-qf2fm4js1z
    @user-qf2fm4js1z 2 года назад

    In solidity 0.5 payable video, there is no fallback function inside the contract Wallet but it can receive ETH, so is the deposit function (#18) of the contract Wallet also a kind of fallback function?

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

    hey sir i have a question why can't we send ethers directly when we deploy our smart contract using value section i have tried it and this shows execution runtime error , but i am not sure why it can't recieve the ethers even when we decalred receive aswell as fallback and why we use low level interaction?

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

    Hello there! Thank you very much for putting together this video series, it is indeed super helpful.
    I am a beginner in the Solidity world and was wondering if you can share a use case example where one would use both "receive" and "fallback" rather than just "fallback"?! From what I understood, "fallback" is enough the handle any use case where value is being sent to the smart contract..
    Cheers!

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

      expresses the intent of your code
      receive means this contract can receive ETH but there is no default function to fallback to

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

    I wonder why fallback(), receive(), and constructor() don't have "function" preceding them.

  • @user-qf2fm4js1z
    @user-qf2fm4js1z 2 года назад

    If there is a payable function like last lesson(#37), still need to have a payable fallback function or payable receive function?

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

      if your contract is going to receive ETH directly, then yes

    • @user-qf2fm4js1z
      @user-qf2fm4js1z 2 года назад

      @@smartcontractprogrammerThanks for your teaching. But I still confuse the difference between "receive ETH directly" and "receive ETH indirectly "? Is to receive ETH directly very risky , otherwise why Fallback payable ?

  • @user-qf2fm4js1z
    @user-qf2fm4js1z 2 года назад

    Excellent Video! When you say"receive ETH directly", is the way you make a demo here to use low level code interaction? And the code and demo in solidity 0.5 fallback is also a kind of "receive ETH directly"? Please advise, Thanks!

  • @NikhilKumar-mm4to
    @NikhilKumar-mm4to 2 года назад

    I cant believe only 6k views, quality is not being valued!

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

    Say that I code a wallet with both fallback() & receive(). If I send native coins to that contract wallet, receive() will listen and emit. But what if I send a token instead? receive() won't get it but will fallback() listen to it? Thanks!

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

    Someone needs to send ether to his payable ...

  • @viktorcortez5706
    @viktorcortez5706 Год назад

    Thanks for your video. I undesrstand what fallback is, but could you explain this? Why is it necessary to use a fallback with flashloan? "A fallback function is called whenever a smart contract iscalled and the selector doesn’t match any of the existing function selectors. It’s basically a catch all.
    Now you can receive generalized flashloans simply by putting all the flashloan logic in the fallback
    function. Be warned there are serious security vulnerabilities that will need to be patched to make
    this function safe to expose."

    • @smartcontractprogrammer
      @smartcontractprogrammer  Год назад +1

      it's not required to have fallback for flashloans

    • @viktorcortez5706
      @viktorcortez5706 Год назад

      @@smartcontractprogrammer yes, but I read one of the manuals from mev searches. So they advise using a fallback when you have several flash loan providers and you simply need to receive funds from them on contract.

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

    cool. didn't know. is it common practice to implement both functions in one contract, or is this more of an academic discussion?

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

    Why the need for the fallback function when we can just create a function that is payable?

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

      fallback is default function and a payable fallback can receive direct transfer of ETH

  • @mrin0
    @mrin0 5 месяцев назад +1

    !

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

    1:38 receive() executed when the data that sent is empty

  • @mertcankose5079
    @mertcankose5079 10 месяцев назад

    okey but why there are two methods? fallback does the two jobs already