Cyfrin Updraft.

Post

Share your knowledge.

Cyfrin Moderator Pst.
Mar 29, 2024
Expert Q&A

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
Share
Comments
.

Answers

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
Official Answer
Comments
.

Do you know the answer?

Please log in and share it.

We use cookies to ensure you get the best experience on our website.
More info