This is my code, I have problem on calling the function from frontend, how can I make function in JS which can interact with my function in smartcontrat?
function placeBet(uint8 matchID, string memory bettingType, uint8 oddForWinning) override external payable MBet {
require(keccak256(abi.encodePacked(bettingType)) == keccak256(abi.encodePacked("Tie")) || keccak256(abi.encodePacked(bettingType)) == keccak256(abi.encodePacked("Team A")) || keccak256(abi.encodePacked(bettingType)) == keccak256(abi.encodePacked("Team B")), "Betting type must be 'Team A' or 'Team B' or 'Tie'");
bets[msg.sender] = Bet(matchID, bettingType, oddForWinning, msg.value);
players.push(msg.sender);
string memory b = "Bet received!";
emit UpdatedBet(msg.sender ,b);
}
The right way to interact with a Smart Contract is via an API. You can then expose the functions of the smart contract via API endpoints (GET/PUT/POST etc).
The right tools to help you achieve that are: Web3.js, Trufflesuite and Ethairballoons.
Then, from the front-end part of your application, you can easily call the API services through which you expose the smart-contract functionality.