I'm trying to create an ERC20 token and if someone sends ether to this contract, contract will send equivalent tokens to the calling address.
Code:::
pragma solidity ^0.6.6;
import "./new1ERC20.sol";
contract ConfigureERC20 is new1ERC20 {
uint256 tokenPrice = 500000000000000 wei;
uint256 public tokensToGet = 0;
fallback() external payable {
require(msg.value > 0);
// require(tokensRemaining > 0);
tokensToGet = msg.value / tokenPrice;
//_balances[] = balances[fundsWallet] - amount;
//_balances[msg.sender] = _balances[msg.sender].add(balance);
emit Transfer(address(this), msg.sender, tokensToGet);
msg.sender.transfer(tokensToGet);
}
}
Thanks!