Transact to MY.transfer errored: VM error: invalid opcode. invalid opcode The execution might have thrown

i have created a smartcontract…

here is the code

    pragma solidity ^0.5.0;

interface IERC20 {
 function totalSupply() external view returns (uint256);
 function balanceOf(address who) external view returns (uint256);
   function allowance(address owner, address spender) external view returns (uint256);
  function transfer(address to, uint256 value) external returns (bool);
  function approve(address spender, uint256 value) external returns (bool);
  function transferFrom(address from, address to, uint256 value) external returns (bool);

 event Transfer(address indexed from, address indexed to, uint256 value);
  event Approval(address indexed owner, address indexed spender, uint256 value);

}

    library SafeMath {
   function mul(uint256 a, uint256 b) internal pure returns (uint256) {
   if (a == 0) {
   return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;

}

     function div(uint256 a, uint256 b) internal pure returns (uint256) {
   uint256 c = a / b;
return c;

}

 function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;

}

function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;

}

function ceil(uint256 a, uint256 m) internal pure returns (uint256) {
uint256 c = add(a,m);
uint256 d = sub(c,1);
return mul(div(d,m),m);

}
}

contract ERC20Detailed is IERC20 {

 string private _name;
 string private _symbol;
 uint8 private _decimals;

 constructor(string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;

}

  function name() public view returns(string memory) {
return _name;

}

 function symbol() public view returns(string memory) {
return _symbol;

}

function decimals() public view returns(uint8) {
return _decimals;

}
}

contract MY is ERC20Detailed {

  using SafeMath for uint256;
  mapping (address => BalanceOwner) private _balances;
 mapping (address => mapping (address => uint256)) private _allowed;
 address[] private _balanceOwners;
 struct BalanceOwner {
  uint256 amount;
  bool exists;

}

 string constant tokenName = "MY";
 string constant tokenSymbol = "NET";
 uint8  constant tokenDecimals = 18;
 uint256 _totalSupply = 1000000000*10**18;
 uint256 public basePercent = 100;


   constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) {
_mint(msg.sender, _totalSupply);

}

 function totalSupply() public view returns (uint256) {
return _totalSupply;

}

function balanceOf(address owner) public view returns (uint256) {
return _balances[owner].amount;

}

 function allowance(address owner, address spender) public view returns (uint256) {
return _allowed[owner][spender];

}

 function findOnePercent(uint256 value) public view returns (uint256)  {
uint256 roundValue = value.ceil(basePercent);
uint256 onePercent = roundValue.mul(basePercent).div(10000);
return onePercent;

}

 function transfer(address to, uint256 value) public returns (bool) {
require(value <= _balances[msg.sender].amount);
require(to != address(0));

uint256 tokensToBurn = findOnePercent(value);
uint256 tokensToRedistribute = tokensToBurn.mul(4);
uint256 tokensToTransfer = value.sub(tokensToBurn + tokensToRedistribute);

_balances[msg.sender].amount = _balances[msg.sender].amount.sub(value);
_balances[to].amount = _balances[to].amount.add(tokensToTransfer);
if (!_balances[to].exists){
    _balanceOwners.push(to);
    _balances[to].exists = true;
}

Hi, if you’re new to this you should follow the tutorial at
OpenZeppelin Upgrades: Step by Step Tutorial for Hardhat.

to get a basic understanding and a working environment.

It will guide you through a test and a deployment.

If you understand that, can you link your testnet contract? I would say something is going wrong with your dev environment.