Verified contractExactMIT
BrutallyRawMover
Address0xd8cc2c3aee0fbdad92e0fcbdf5a7392e2390cc9d
- Balance
0 ETH
- Transactions
13
- Compiler
solc 0.8.34
- Same code
Only this contract
Details
- Compiler
- solc 0.8.34+commit.80d5c536
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 24,881,701
- Creation transaction
- 0x9e80fb9ce7…a3dd6adcab
BRmover.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC721Minimal {
function ownerOf(uint256 tokenId) external view returns (address);
function isApprovedForAll(address owner, address operator) external view returns (bool);
function getApproved(uint256 tokenId) external view returns (address);
function transferFrom(address from, address to, uint256 tokenId) external;
}
interface IERC20Minimal {
function transfer(address to, uint256 amount) external returns (bool);
}
contract BrutallyRawMover {
// Hardcoded ERC721 collection
address public constant COLLECTION = 0x3Aca56e506d47218364Ff066a4127ba2895A3409;
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event BatchMoved(address indexed caller, address indexed from, address indexed to, uint256 count);
event BatchMovedMany(address indexed caller, address indexed from, uint256 count);
event ERC721Rescued(address indexed token, uint256 indexed tokenId, address indexed to);
event ERC20Rescued(address indexed token, address indexed to, uint256 amount);
event ETHRescued(address indexed to, uint256 amount);
error NotOwner();
error NotAuthorized(address caller, address from);
error ZeroAddress();
error EmptyArray();
error LengthMismatch();
error InvalidRange();
error NotTokenOwner(uint256 tokenId, address expectedOwner, address actualOwner);
error ContractNotApproved(address tokenOwner, address operator);
error ERC20TransferFailed();
error ETHTransferFailed();
modifier onlyOwner() {
if (msg.sender != owner) revert NotOwner();
_;
}
constructor() {
owner = msg.sender;
emit OwnershipTransferred(address(0), msg.sender);
}
receive() external payable {}
function transferOwnership(address newOwner) external onlyOwner {
if (newOwner == address(0)) revert ZeroAddress();
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
function renounceOwnership() external onlyOwner {
emit OwnershipTransferred(owner, address(0));
owner = address(0);
}
/// @notice Move many token IDs from your wallet to one destination
/// @dev Caller must be the `from` wallet
function batchMove(
address from,
address to,
uint256[] calldata tokenIds
) external {
if (from != msg.sender) revert NotAuthorized(msg.sender, from);
if (from == address(0) || to == address(0)) revert ZeroAddress();
if (tokenIds.length == 0) revert EmptyArray();
IERC721Minimal nft = IERC721Minimal(COLLECTION);
bool approvedForAll = nft.isApprovedForAll(from, address(this));
for (uint256 i = 0; i < tokenIds.length; ++i) {
uint256 tokenId = tokenIds[i];
address actualOwner = nft.ownerOf(tokenId);
if (actualOwner != from) {
revert NotTokenOwner(tokenId, from, actualOwner);
}
if (!approvedForAll && nft.getApproved(tokenId) != address(this)) {
revert ContractNotApproved(from, address(this));
}
nft.transferFrom(from, to, tokenId);
}
emit BatchMoved(msg.sender, from, to, tokenIds.length);
}
/// @notice Move a sequential inclusive range of token IDs from your wallet to one destination
/// @dev Range is startId..endId
function batchMoveRange(
address from,
address to,
uint256 startId,
uint256 endId
) external {
if (from != msg.sender) revert NotAuthorized(msg.sender, from);
if (from == address(0) || to == address(0)) revert ZeroAddress();
if (endId < startId) revert InvalidRange();
IERC721Minimal nft = IERC721Minimal(COLLECTION);
bool approvedForAll = nft.isApprovedForAll(from, address(this));
uint256 count = 0;
for (uint256 tokenId = startId; tokenId <= endId; ++tokenId) {
address actualOwner = nft.ownerOf(tokenId);
if (actualOwner != from) {
revert NotTokenOwner(tokenId, from, actualOwner);
}
if (!approvedForAll && nft.getApproved(tokenId) != address(this)) {
revert ContractNotApproved(from, address(this));
}
nft.transferFrom(from, to, tokenId);
unchecked {
++count;
}
if (tokenId == type(uint256).max) break;
}
emit BatchMoved(msg.sender, from, to, count);
}
/// @notice Move tokens from your wallet to many recipients
/// @dev tokenIds[i] goes to recipients[i]
function batchMoveMany(
address from,
address[] calldata recipients,
uint256[] calldata tokenIds
) external {
if (from != msg.sender) revert NotAuthorized(msg.sender, from);
if (from == address(0)) revert ZeroAddress();
if (tokenIds.length == 0) revert EmptyArray();
if (recipients.length != tokenIds.length) revert LengthMismatch();
IERC721Minimal nft = IERC721Minimal(COLLECTION);
bool approvedForAll = nft.isApprovedForAll(from, address(this));
for (uint256 i = 0; i < tokenIds.length; ++i) {
address to = recipients[i];
if (to == address(0)) revert ZeroAddress();
uint256 tokenId = tokenIds[i];
address actualOwner = nft.ownerOf(tokenId);
if (actualOwner != from) {
revert NotTokenOwner(tokenId, from, actualOwner);
}
if (!approvedForAll && nft.getApproved(tokenId) != address(this)) {
revert ContractNotApproved(from, address(this));
}
nft.transferFrom(from, to, tokenId);
}
emit BatchMovedMany(msg.sender, from, tokenIds.length);
}
/// @notice Rescue any ERC721 accidentally sent to this contract
function rescueERC721(
address token,
uint256 tokenId,
address to
) external onlyOwner {
if (token == address(0) || to == address(0)) revert ZeroAddress();
IERC721Minimal(token).transferFrom(address(this), to, tokenId);
emit ERC721Rescued(token, tokenId, to);
}
/// @notice Rescue any ERC20 accidentally sent to this contract
function rescueERC20(
address token,
address to,
uint256 amount
) external onlyOwner {
if (token == address(0) || to == address(0)) revert ZeroAddress();
bool ok = IERC20Minimal(token).transfer(to, amount);
if (!ok) revert ERC20TransferFailed();
emit ERC20Rescued(token, to, amount);
}
/// @notice Rescue ETH accidentally sent to this contract
function rescueETH(address payable to, uint256 amount) external onlyOwner {
if (to == address(0)) revert ZeroAddress();
(bool ok, ) = to.call{value: amount}("");
if (!ok) revert ETHTransferFailed();
emit ETHRescued(to, amount);
}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.