How to remove this error Gas estimation error with the following message (see below). The transaction execution will likely fail. Internal JSON-RPC error. i am not understanding why this error is there, mainly in this two functions
function buyTokens() public payable {
uint tokenAmount = msg.value * rate;
require(token.balanceOf(address(this)) >= tokenAmount); token.transfer(msg.sender, tokenAmount);
emit TokensPurchased(msg.sender, address(token), tokenAmount, rate);
}
function sellTokens(uint _amount) public {
require(token.balanceOf(msg.sender) >= _amount);
uint etherAmount = _amount / rate;
require(address(this).balance >= etherAmount);
token.transferFrom(msg.sender, address(this), _amount);
msg.sender.transfer(etherAmount);
emit TokensSold(msg.sender, address(token), _amount, rate);
}