Description:
Smart contract deployed on Ethereum.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC20 {
function balanceOf(address) external view returns (uint256);
function transfer(address, uint256) external returns (bool);
}
contract ToolV2 {
address public owner;
modifier onlyOwner() { require(msg.sender == owner, "only owner"); _; }
event Step(string indexed tag, bool ok, bytes ret);
event SnapshotTried(uint256 indexed idx, bool ok);
constructor() { owner = msg.sender; }
receive() external payable {}
// internal low-level helper (value 可传 0 或 msg.value)
function _call(address to, bytes memory data, uint256 value, bool strict, string memory tag) internal {
(bool ok, bytes memory ret) = to.call{value: value}(data);
emit Step(tag, ok, ret);
if (strict) require(ok, tag);
}
function tx0_executeSs(address zhenzi, uint256 times) external onlyOwner {
bytes4 sel = 0x73eaaed5; //
for (uint256 i = 0; i < times; ++i) {
(bool ok,) = zhenzi.call(abi.encodeWithSelector(sel));
// ignore revert / continue
}
}
function tx1a_getzhenziTokens(address zhenzi, bool strict) external payable onlyOwner {
bytes4 sel = 0x6aa19a69;
_call(zhenzi, abi.encodeWithSelector(sel, address(this)), msg.value, strict, "getzhenziTokens");
}
function tx1b_sendwaibudaibi(address zhenzi, address externalToken, bool strict) external onlyOwner {
bytes4 sel = 0xe8068889;
_call(zhenzi, abi.encodeWithSelector(sel, address(this), externalToken), 0, strict, "sendwaibudaibi");
}
function tx1c_voteByTransferAll(address zhenzi, address externalToken, bool strict) external onlyOwner {
(bool okT, bytes memory ret) = zhenzi.staticcall(
abi.encodeWithSelector(bytes4(keccak256("token()")))
);
emit Step("token()", okT, ret);
require(okT && ret.length >= 32, "token() failed");
address work = abi.decode(ret, (address));
uint256 bal = IERC20(work).balanceOf(address(this));
emit Step("work.balanceOf(this)", true, abi.encode(bal));
if (bal > 0) {
bool ok = IERC20(work).transfer(externalToken, bal);
emit Step("work.transfer(all)", ok, "");
if (strict) require(ok, "transfer(work->externalToken) failed");
}
}
function tx1_doGTST(address zhenzi, address waibudaibi) external payable onlyOwner {
bytes4 sel_getZhenzi = 0x6aa19a69;
(bool okGet, ) = zhenzi.call{value: msg.value}(abi.encodeWithSelector(sel_getZhenzi, address(this)));
bytes4 sel_sendExt = 0xe8068889;
(bool okSend, ) = zhenzi.call(abi.encodeWithSelector(sel_sendExt, address(this), waibudaibi));
bytes4 sel_token = bytes4(keccak256("token()"));
(bool okTokenCall, bytes memory ret) = zhenzi.staticcall(abi.encodeWithSelector(sel_token));
address workAddr = address(0);
if (okTokenCall && ret.length >= 32) {
workAddr = abi.decode(ret, (address));
}
if (workAddr != address(0)) {
uint256 bal = IERC20(workAddr).balanceOf(address(this));
bool okTransfer = false;
if (bal > 0) {
okTransfer = IERC20(workAddr).transfer(waibudaibi, bal);
}
}
}
function tx2_ssc(address zhenzi) external onlyOwner {
bytes4 sel_snap = 0x73eaaed5;
(bool okSnap, ) = zhenzi.call(abi.encodeWithSelector(sel_snap));
bytes4 sel_claim = 0x693d0df2;
(bool okClaim, ) = zhenzi.call(abi.encodeWithSelector(sel_claim, address(this)));
}
// owner ops
function withdrawETH(address payable to) external onlyOwner {
(bool ok,) = to.call{value: address(this).balance}("");
require(ok, "eth send failed");
}
function withdrawERC20(address token, address to) external onlyOwner {
uint256 bal = IERC20(token).balanceOf(address(this));
require(IERC20(token).transfer(to, bal), "erc20 transfer failed");
}
function setowner(address newOwner) external onlyOwner { require(newOwner != address(0), "zero"); owner = newOwner; }
}
Submitted on: 2025-10-16 09:11:21
Comments
Log in to comment.
No comments yet.