Smart contract does not work.testing goerli

I try to create a contract which reads the current price of a token. This contract will receive eth in deposit. Then reading the amount received it will send the corresponding amount of tokens to the address that sent those eth to the contract.
A kind of swap but internal to the contract.
What I really want to do is that the addresses can exchange eth for a specific token but only by executing orders to send that token, so the user who sends eth only pays the sending fee and the contract sends that token that it already has previously.

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

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";

contract Mother is Ownable {
    address private constant MUZZ_ADDRESS = 0xef3dAa5fDa8Ad7aabFF4658f1F78061fd626B8f0;
    address private constant MUZZ_ETH_PAIR = 0x06D9CdDD7FCaF2e93573D04bE5DE2fc4dEA45F45;
    address private muzzTokenAddress; // declare the variable muzzTokenAddress
    address private muzzEthPairAddress; // declare the variable muzzTokenAddress
    constructor() Ownable(msg.sender) {
        // Constructor de la clase Ownable con la dirección del propietario inicial
    function setMuzzTokenAddress(address _muzzTokenAddress) external onlyOwner {
        muzzTokenAddress = _muzzTokenAddress;

    function setMuzzEthPairAddress(address _muzzEthPairAddress) external onlyOwner {
        muzzEthPairAddress = _muzzEthPairAddress;

    function deposit() external payable {
        // Función para recibir ETH

    function depositToken(address token, uint256 amount) external {
        IERC20(token).transferFrom(msg.sender, address(this), amount);

    function withdrawEth(uint256 amount) external onlyOwner {
        require(amount <= address(this).balance, "Insufficient ETH balance");

    function withdrawToken(address token, uint256 amount) external onlyOwner {
        require(IERC20(token).balanceOf(address(this)) >= amount, "Insufficient token balance");
        IERC20(token).transfer(owner(), amount);

    function autoSendTokens() external onlyOwner {
        uint256 ethReceived = address(this).balance;
        require(ethReceived > 0, "No ETH received");

        uint256 muzzPrice = getUniswapPrice(MUZZ_ETH_PAIR);
        uint256 tokensToSend = calculateTokens(ethReceived, muzzPrice);
        sendTokens(MUZZ_ADDRESS, tokensToSend, msg.sender);

    function getUniswapPrice(address pairAddress) internal view returns (uint256 price) {
        IUniswapV2Pair pair = IUniswapV2Pair(pairAddress);
        (uint112 reserve0, uint112 reserve1, ) = pair.getReserves();

        if (reserve0 > 0) {
            price = (uint256(reserve1) * 1e18) / uint256(reserve0);

    function calculateTokens(uint256 ethAmount, uint256 price) internal pure returns (uint256) {
        uint256 tokensToSend = (ethAmount * price * 98) / (100 * 1e18);
        return tokensToSend;

    function sendTokens(address token, uint256 amount, address recipient) internal {
        require(IERC20(token).balanceOf(address(this)) >= amount, "Insufficient token balance");
        IERC20(token).transfer(recipient, amount);

Please elaborate more than "does not work":

  • What contract function are you calling?
  • What input values are you passing to it?
  • What error-message are you receiving?
  • What is the address of your contract?
  • What is the hash of your failing transaction?

Contract add: 0x942802e74fA8A5cc3D4Ff50489bB71Cd28341F4F
I want the contract to send the token automatically, and it doesn't. Even when I run the autosent function, it doesn't do it either.

hash : 0x320732dd42f871c469eef77ab3d73713768bdbf99fb145dafd50dd2ea10aafd9

My answer was very clear - a simple list of details which you should (and easily can) provide.
Why not follow it? Are we supposed to guess which function you are calling and what input values you are passing to it?

And by the way:

There's no such function in your contract, and what does "Even" even means here? Do you expect something to happen when you... do nothing at all?

Sorry. I will take a good look at it and you respond appropriately.