账户
0xcb...f742
0xcB...f742

0xcB...f742

$500
此合同的源代码已经过验证!
合同元数据
编译器
0.8.19+commit.7dd6d404
语言
Solidity
合同源代码
文件 1 的 3:Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
合同源代码
文件 2 的 3:Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
合同源代码
文件 3 的 3:Subscription.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/access/Ownable.sol";

contract Subscription is Ownable {
    address public subscriptionWallet =
        0x241397fa0B3023a9CF37C13A7083013e0511853A;
    address public revenueWallet = 0xff5EDB0A0682D4B3d27495E2B00A324d8f5c16b9;
    uint256 feeSub = 7500;

    event SubscriptionTransferred(address indexed to, uint256 amount);

    constructor() {}

    function setSubscriptionWallet(
        address _subscriptionWallet
    ) external onlyOwner {
        require(_subscriptionWallet != address(0), "Invalid address");
        subscriptionWallet = _subscriptionWallet;
    }

    function setRevenueWallet(address _revenueWallet) external onlyOwner {
        require(_revenueWallet != address(0), "Invalid address");
        revenueWallet = _revenueWallet;
    }

    function setFeeSub(uint256 _feeSub) external onlyOwner {
        require(_feeSub <= 10000, "Invalid fee tax");
        feeSub = _feeSub;
    }

    function deposit(address _refAddress, uint _feeTax) external payable {
        require(_refAddress != address(0), "Invalid ref address");
        require(feeSub + _feeTax <= 10000, "Invalid fee tax");
        uint256 subAmount = (msg.value * feeSub) / 10000;
        uint256 refAmount = (msg.value * _feeTax) / 10000;

        (bool success1, ) = subscriptionWallet.call{value: subAmount}("");
        require(success1, "Failed to send subscriptionWallet");

        (bool success2, ) = _refAddress.call{value: refAmount}("");
        require(success2, "Failed to send refAddress");

        if (msg.value > refAmount + subAmount) {
            (bool success3, ) = revenueWallet.call{
                value: msg.value - refAmount - subAmount
            }("");
            require(success3, "Failed to send revenueWallet");
        }
        emit SubscriptionTransferred(_refAddress, refAmount);
    }
}
设置
{
  "compilationTarget": {
    "contracts/Subscription.sol": "Subscription"
  },
  "evmVersion": "paris",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "optimizer": {
    "enabled": false,
    "runs": 200
  },
  "remappings": []
}
ABI
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SubscriptionTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"_refAddress","type":"address"},{"internalType":"uint256","name":"_feeTax","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revenueWallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_feeSub","type":"uint256"}],"name":"setFeeSub","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_revenueWallet","type":"address"}],"name":"setRevenueWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_subscriptionWallet","type":"address"}],"name":"setSubscriptionWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"subscriptionWallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]