简体   繁体   English

Solidity 结构和质押代码错误:请查看合约

[英]Solidity struct and staking code error: Please look into the contract

I had built a staking contract but while testing the staking it's throwing The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.我已经建立了一个质押合约,但在测试质押时它正在抛出The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information. The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information. this error.这个错误。 My code is `我的代码是`

function startGame(address secondPlayer, string memory phrase, uint _amount) external { 

require(token.balanceOf(msg.sender) >= _amount); uint _stakedAmountChallenger = stakeZug(_amount);
    uint secret =uint(keccak256(abi.encodePacked(phrase)));

matchLists.push(matchUps(matchStatus.Start,msg.sender,secondPlayer,_stakedAmountChallenger,0,_stakedAmountChallenger,secret,false));
                uint gameNumber = matchLists.length -1;
                isValid[gameNumber] = true;
                emit challengeInitiator(msg.sender, secondPlayer, false, gameNumber);
            }

` `

Add the 'payable' specifier to the function description:将“应付”说明符添加到 function 描述中:

function startGame(...) external payable { function startGame(...) 外部支付{

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM