github.com/iotexproject/iotex-core@v1.14.1-rc1/action/protocol/execution/testdata-shanghai/send-eth.sol (about)

     1  // SPDX-License-Identifier: GPL-3.0
     2  
     3  pragma solidity ^0.8.14;
     4  
     5  contract MyContract {
     6      constructor() payable {}
     7  
     8      address a = 0x1e14d5373E1AF9Cc77F0032aD2cd0FBA8be5Ea2e;
     9  
    10      function transferTo() public payable {}
    11  
    12      function foo() public {
    13          // send ether with default 21,000 gas
    14          // likely causes OOG in callee
    15          payable(a).transfer(1 ether);
    16  
    17          // send ether with all remaining gas
    18          // but no success check!
    19          payable(a).call{value: 1 ether}("");
    20  
    21          // RECOMMENDED
    22          // send all remaining gas
    23          // explicitly handle callee throw
    24          bool ok;
    25          bytes memory ret;
    26          (ok, ret) = a.call{value: 1 ether}("");
    27          if (!ok) revert();
    28      }
    29  }