Events 固态事件n发射syntex
希望一切顺利 我想在下面的solidity代码中执行以下活动,但不知道如何执行,请提供建议。 谢谢你的问候 赛义德 查询:_ 发出一个带有两个参数的事件:int amount(等于发送的值)和bool direction(true表示向上函数,false表示向下函数) 在gameOver切换为true后发出事件GameEnded 代码:Events 固态事件n发射syntex,events,solidity,emit,syntex,Events,Solidity,Emit,Syntex,希望一切顺利 我想在下面的solidity代码中执行以下活动,但不知道如何执行,请提供建议。 谢谢你的问候 赛义德 查询:_ 发出一个带有两个参数的事件:int amount(等于发送的值)和bool direction(true表示向上函数,false表示向下函数) 在gameOver切换为true后发出事件GameEnded 代码: pragma-solidity^0.4.17; 合同拖船{ int公共分数=0; int常数endAt=1乙醚; bool public gameOver=fa
pragma-solidity^0.4.17;
合同拖船{
int公共分数=0;
int常数endAt=1乙醚;
bool public gameOver=false;
函数up()外部应付款{
需要(msg.value>0);
需要(!gameOver);
int value=int(消息值);
分数+=价值;
checkIfGameOver();
}
函数down()外部应付款{
需要(msg.value>0);
需要(!gameOver);
int value=int(消息值);
分数-=价值;
checkIfGameOver();
}
函数checkIfGameOver()内部{
如果(分数>=endAt | |分数,则可以通过以下方式定义合同中的事件:
event ScoreChanged(uint amount, bool up);
event GameEnded(bool up); // where 'up' indicates which side won.
要发出您写入的事件,请执行以下操作:
emit ScoreChanged(msg.value, true); // where the second argument indicates the direction
您可以在增加或减少分数后立即执行此操作
当游戏结束时:
emit GameEnded(true); // where the argument indicates which side has won.
您可以通过以下方式定义合同中的事件:
event ScoreChanged(uint amount, bool up);
event GameEnded(bool up); // where 'up' indicates which side won.
要发出您写入的事件,请执行以下操作:
emit ScoreChanged(msg.value, true); // where the second argument indicates the direction
您可以在增加或减少分数后立即执行此操作
当游戏结束时:
emit GameEnded(true); // where the argument indicates which side has won.