Cyfrin Updraft.

帖子

分享您的知识。

Cyfrin Moderator Pst.
Mar 29, 2024
专家问答

Which function selector and input data should be used in solveChallenge?

I am working on the solveChallenge function which requires a function selector and input data to be passed. I am unsure about which function I should get the function selector for, and what the input data should be that needs to be turned into bytes. Any guidance on this would be greatly appreciated. Thank you in advance for your help.

function solveChallenge(bytes4 selectorOne, bytes memory inputData, string memory yourTwitterHandle) external {
 (bool successOne, bytes memory responseDataOne) = i_helperContract.call(abi.encodeWithSelector(selectorOne));
 if (!successOne || uint256(bytes32((responseDataOne))) != 1) {
 revert S1__WrongSelector();
 }

 (bool successTwo, bytes memory responseDataTwo) = i_helperContract.call(inputData);
 if (!successTwo || uint256(bytes32((responseDataTwo))) != 1) {
 revert S1__WrongData();
 }
 _updateAndRewardSolver(yourTwitterHandle);
}

I am motivated to understand how to find the solution, not just for obtaining the NFT. Thank you for your assistance.

  • Transaction
  • Solidity
  • Smart Contract
0
1
分享
评论
.

答案

1
Cyfrin Moderator Ans.
Mar 29 2024, 10:50

It appears that I overlooked the significance of the i_helperContract in the context of the solveChallenge function. When solveChallenge is invoked, it initiates a call to the i_helperContract. Within the i_helperContract, there exists a function named returnTrue for which we require the function selector.

In order to fulfill the requirements, it is necessary to obtain the function selector for returnTrue. Subsequently, when invoking solveChallenge, the function selector of returnTrue should be provided as input arguments to selectorOne and inputData.

0
官方答案
评论
.

你知道答案吗?

请登录并分享。

Cyfrin Updraft is an education platform specializing on teaching the next generation of smart contract developers

195帖子196答案
我们使用 cookie 确保您在我们的网站上获得最佳体验。
更多信息