EthereumFeeProxy

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "@openzeppelin/contracts/security/ReentrancyGuard.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}
"
    },
    "contracts/EthereumFeeProxy.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.0;\r
\r
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";\r
\r
/**\r
 * @title EthereumFeeProxy\r
 * @notice This contract performs an Ethereum transfer with a Fee sent to a third address and stores a reference\r
 */\r
contract EthereumFeeProxy is ReentrancyGuard {\r
    // Event to declare a transfer with a reference\r
    event TransferWithReferenceAndFee(\r
        address to,\r
        uint256 amount,\r
        bytes indexed paymentReference,\r
        uint256 feeAmount,\r
        address feeAddress\r
    );\r
\r
    // Fallback function returns funds to the sender\r
    receive() external payable {\r
        revert("not payable receive");\r
    }\r
\r
    /**\r
     * @notice Gets native token hash\r
     */\r
    function getAmountValue() external view returns (uint256 amount) {}\r
\r
    /**\r
     * @notice Performs an Ethereum transfer with a reference\r
     * @param _to Transfer recipient\r
     * @param _paymentReference Reference of the payment related\r
     * @param _feeAmount The amount of the payment fee (part of the msg.value)\r
     * @param _feeAddress The fee recipient\r
     */\r
    function transferWithReferenceAndFee(\r
        address payable _to,\r
        bytes calldata _paymentReference,\r
        uint256 _feeAmount,\r
        address payable _feeAddress\r
    ) external payable {\r
        transferExactEthWithReferenceAndFee(\r
            _to,\r
            msg.value - _feeAmount,\r
            _paymentReference,\r
            _feeAmount,\r
            _feeAddress\r
        );\r
    }\r
\r
    /**\r
     * @notice Performs an Ethereum transfer with a reference with an exact amount of eth\r
     * @param _to Transfer recipient\r
     * @param _amount Amount to transfer\r
     * @param _paymentReference Reference of the payment related\r
     * @param _feeAmount The amount of the payment fee (part of the msg.value)\r
     * @param _feeAddress The fee recipient\r
     */\r
    function transferExactEthWithReferenceAndFee(\r
        address payable _to,\r
        uint256 _amount,\r
        bytes calldata _paymentReference,\r
        uint256 _feeAmount,\r
        address payable _feeAddress\r
    ) public payable nonReentrant {\r
        (bool sendSuccess, ) = _to.call{value: _amount}("");\r
        require(sendSuccess, "Could not pay the recipient");\r
\r
        _feeAddress.transfer(_feeAmount);\r
\r
        // transfer the remaining ethers to the sender\r
        (bool sendBackSuccess, ) = payable(msg.sender).call{\r
            value: msg.value - _amount - _feeAmount\r
        }("");\r
        require(sendBackSuccess, "Could not send remaining funds to the payer");\r
\r
        emit TransferWithReferenceAndFee(\r
            _to,\r
            _amount,\r
            _paymentReference,\r
            _feeAmount,\r
            _feeAddress\r
        );\r
    }\r
}\r
"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "evmVersion": "paris",
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "metadata": {
      "useLiteralContent": true
    }
  }
}}

Tags:
Factory|addr:0xc4a5121feaecc02d5bebbfd75f5beb649ee75249|verified:true|block:23718686|tx:0x1c9512078384ff75aac74f1b5da75ed4df73daa234d46ccdc9e2968d5ade6507|first_check:1762175148

Submitted on: 2025-11-03 14:05:48

Comments

Log in to comment.

No comments yet.