firstly, I have a code in a contract as below:
receive() external payable {
// function enter() external payable {
require(msg.value > 0.1 ether, "require minimum 0.1 ether! ");
players.push(payable(msg.sender));
}
then I test it in the ganache with mocha and web3.js, the js code as below:
await mycontract.send({
from: accounts[1],
value: web3.utils.toWei('2', 'ether')
});
but got the error TypeError: mycontract.send is not a function
then I update the contract as function enter() external payable
, so js works as below:
await mycontract.methods.enter().send({
from: accounts[2],
value: web3.utils.toWei('2', 'ether')
});
But I'm wondering is there a solution as I wrote as the first type?