编译器
0.8.19+commit.7dd6d404
文件 1 的 3:Context.sol
pragma solidity ^0.8.0;
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
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 3 的 3:Subscription.sol
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": []
}
[{"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"}]