TokenApprove

0x42170295f1173c9e5874ea9d00c6d137e1a4f53d

Verification
Verified
v0.8.17+commit.8df45f5f
Type
Contract
1,605 bytes
ABI entries
11
2 read · 5 write
License
none

Contract information

Address
0x42170295f1173c9e5874ea9d00c6d137e1a4f53d
Chain
Robinhood Chain (4663)
Compiler
v0.8.17+commit.8df45f5f
Optimization
Enabled
Creation tx
0x228efa25cb…35f848f5d7

Token

Not a token

This contract does not expose ERC-20 metadata.

Read contract (2)

owner()address
tokenApproveProxy()address

Events (3)

InitializedOwnershipTransferredProxyUpdate

ABI

[
  {
    "inputs": [],
    "name": "SafeTransferFromFailed",
    "type": "error"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": false,
        "internalType": "uint8",
        "name": "version",
        "type": "uint8"
      }
    ],
    "name": "Initialized",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "previousOwner",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "newOwner",
        "type": "address"
      }
    ],
    "name": "OwnershipTransferred",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "oldProxy",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "newProxy",
        "type": "address"
      }
    ],
    "name": "ProxyUpdate",
    "type": "event"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "_token",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "_who",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "_dest",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "_amount",
        "type": "uint256"
      }
    ],
    "name": "claimTokens",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "_tokenApproveProxy",
        "type": "address"
      }
    ],
    "name": "initialize",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "owner",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "renounceOwnership",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "_newTokenApproveProxy",
        "type": "address"
      }
    ],
    "name": "setApproveProxy",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "tokenApproveProxy",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "newOwner",
        "type": "address"
      }
    ],
    "name": "transferOwnership",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  }
]

Source code

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "./interfaces/IERC20.sol";
import "./libraries/SafeERC20.sol";

/// @title Handle authorizations in dex platform
/// @notice This contract is used to manage token approvals and ensure safe token transfers on a DEX platform.
/// @dev This contract utilizes the SafeERC20 library for secure token transfers and provides functionality to update the approval proxy address.
contract TokenApprove is OwnableUpgradeable {
    using SafeERC20 for IERC20;

    /// @notice The address authorized to initiate token transfers on behalf of users.
    address public tokenApproveProxy;

    /// @notice Initializes the contract by setting the token approval proxy address.
    /// @param _tokenApproveProxy The address authorized to initiate token transfers.
    function initialize(address _tokenApproveProxy) public initializer {
        __Ownable_init();
        tokenApproveProxy = _tokenApproveProxy;
    }

    //-------------------------------
    //------- Events ----------------
    //-------------------------------

    /// @notice Emitted when the token approval proxy address is updated.
    /// @param oldProxy The previous proxy address.
    /// @param newProxy The new proxy address.
    event ProxyUpdate(address indexed oldProxy, address indexed newProxy);

    //---------------------------------
    //------- Admin functions ---------
    //---------------------------------

    /// @notice Updates the token approval proxy address.
    /// @param _newTokenApproveProxy The new address authorized to initiate token transfers.
    /// @dev Can only be called by the contract owner.
    function setApproveProxy(address _newTokenApproveProxy) external onlyOwner {
        emit ProxyUpdate(tokenApproveProxy, _newTokenApproveProxy);
        tokenApproveProxy = _newTokenApproveProxy;
    }

    //---------------------------------
    //-------  User Functions --------
    //---------------------------------

    /// @notice Transfers tokens from one address to another on behalf of the token owner, using a pre-approved allowance.
    /// @param _token The address of the token to be transferred.
    /// @param _who The address of the token owner (the sender).
    /// @param _dest The address of the recipient (the receiver).
    /// @param _amount The amount of tokens to be transferred.
    /// @dev This function can only be called by the address set as `tokenApproveProxy`.
    function claimTokens(
        address _token,
        address _who,
        address _dest,
        uint256 _amount
    ) external {
        require(
            msg.sender == tokenApproveProxy,
            "TokenApprove: Access restricted"
        );
        if (_amount > 0) {
            IERC20(_token).safeTransferFrom(_who, _dest, _amount);
        }
    }
}
Chain explorer771msChain node82ms