createNewGame: function() {
TicTacToe.new({from : account , value : Web3.utils.toWei("0.1","ether")}).then(instance => {
ticTacToeInstance = instance;
// var playerJoinedEvent = ticTacToeInstance.PlayerJoined();
ticTacToeInstance.events.PlayerJoined((error,eventObj) => {
if(!error)
{
console.log(eventObj);
/*
//Reacting to click events on the board
*/
}
else{
console.log(error);
}
})
console.log(instance);
}).catch(error => {
console.log(error);
})
}
Это код надежности, который генерирует событие PlayerJoined.
function joinGame() public payable
{
assert(player2 == address(0));
require(msg.value == gameCost);
gameActive = true;
player2 = msg.sender;
emit PlayerJoined(player2);
//Randomising who initiates the game
if(block.number % 2 == 0)
{
activePlayer = player2;
}
else
{
activePlayer = player1;
}
emit NextPlayer(activePlayer);
gameValidUntil = now + timeToReact;
}
Я использую версию web3 1.2.1.
TypeError: невозможно прочитать свойство PlayerJoined для undefined в eval (index. js: 69)
Пожалуйста, помогите мне.