// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract ExchangeTest {
address owner;
address addr;
mapping(address => uint256) balancesToken;
constructor() {
owner = msg.sender;
addr = address(this);
}
function EthToToken() public payable {
balancesToken[msg.sender] += msg.value;
}
function TokenToEth(uint256 val) public payable {
require(addr.balance >= val, "Not enougt eth");
require(msg.sender == owner, "Not a round");
address sender = msg.sender;
balancesToken[sender] -= val;
payable(sender).transfer(val);
}
}
VM Exception while processing transaction: revert
Maybe this is due to the fact that I transfer and withdraw funds for the contract not directly, but through another contract? I also call contracts with web3.py.