Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"forward.sol": {
"content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.20;\r
\r
contract Forward {\r
address public owner;\r
address public defaultTo; // default destination\r
\r
modifier onlyOwner() {\r
require(msg.sender == owner, "not owner");\r
_;\r
}\r
\r
/* ---------- constructor ---------- */\r
constructor(address _initialDestination) {\r
require(_initialDestination != address(0), "bad destination");\r
owner = msg.sender;\r
defaultTo = _initialDestination;\r
}\r
\r
/* ---------- owner management ---------- */\r
function setDefaultForwardAddress(address _newTo) external onlyOwner {\r
require(_newTo != address(0), "bad destination");\r
defaultTo = _newTo;\r
}\r
\r
/* ---------- fallback & explicit forward ---------- */\r
// plain ETH transfer → use stored address\r
receive() external payable {\r
_forward(defaultTo);\r
}\r
\r
// keep the original interface untouched\r
function forward(address _to) external payable {\r
_forward(_to);\r
}\r
\r
/* ---------- internal worker ---------- */\r
function _forward(address _to) internal {\r
require(msg.value > 0 && _to != address(0), "Bad input");\r
(bool ok,) = _to.call{value: msg.value}("");\r
require(ok, "Forward failed");\r
}\r
}"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": []
}
}}
Submitted on: 2025-09-25 11:24:27
Comments
Log in to comment.
No comments yet.