<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 回退函數(fallback function) 每一個合約有且僅有一個沒有名字的函數。這個函數無參數,也無返回值。如果調用合約時,沒有匹配上任何一個函數(或者沒有傳哪怕一點數據),就會調用默認的回退函數。 此外,當合約收到`ether`時(沒有任何其它數據),這個函數也會被執行。在此時,一般僅有少量的gas剩余,用于執行這個函數(準確的說,還剩2300gas)。所以應該盡量保證回退函數使用少的gas。 下述提供給回退函數可執行的操作會比常規的花費得多一點。 - 寫入到存儲(storage) - 創建一個合約 - 執行一個外部(external)函數調用,會花費非常多的gas - 發送`ether` 請在部署合約到網絡前,保證透徹的測試你的回退函數,來保證函數執行的花費控制在2300gas以內。 一個沒有定義一個回退函數的合約。如果接收ether,會觸發異常,并返還ether(solidity v0.4.0開始)。所以合約要接收ether,必須實現回退函數。下面來看個例子: ``` pragma solidity ^0.4.0; contract Test { // This function is called for all messages sent to // this contract (there is no other function). // Sending Ether to this contract will cause an exception, // because the fallback function does not have the "payable" // modifier. function() { x = 1; } uint x; } // This contract keeps all Ether sent to it with no way // to get it back. contract Sink { function() payable { } } contract Caller { function callTest(Test test) { test.call(0xabcdef01); // hash does not exist // results in test.x becoming == 1. // The following call will fail, reject the // Ether and return false: test.send(2 ether); } } ``` 在瀏覽器中跑的話,記得要先存ether。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看