github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/src/libraries/Burn.sol (about)

     1  // SPDX-License-Identifier: MIT
     2  pragma solidity 0.8.15;
     3  
     4  /// @title Burn
     5  /// @notice Utilities for burning stuff.
     6  library Burn {
     7      /// @notice Burns a given amount of ETH.
     8      /// @param _amount Amount of ETH to burn.
     9      function eth(uint256 _amount) internal {
    10          new Burner{ value: _amount }();
    11      }
    12  
    13      /// @notice Burns a given amount of gas.
    14      /// @param _amount Amount of gas to burn.
    15      function gas(uint256 _amount) internal view {
    16          uint256 i = 0;
    17          uint256 initialGas = gasleft();
    18          while (initialGas - gasleft() < _amount) {
    19              ++i;
    20          }
    21      }
    22  }
    23  
    24  /// @title Burner
    25  /// @notice Burner self-destructs on creation and sends all ETH to itself, removing all ETH given to
    26  ///         the contract from the circulating supply. Self-destructing is the only way to remove ETH
    27  ///         from the circulating supply.
    28  contract Burner {
    29      constructor() payable {
    30          selfdestruct(payable(address(this)));
    31      }
    32  }