Cyfrin Updraft.

Bài viết

Chia sẻ kiến thức của bạn.

Cyfrin Moderator Pst.
Mar 29, 2024
Hỏi đáp Chuyên Gia

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
Chia sẻ
Bình luận
.

Câu trả lời

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
Câu trả lời chính thức
Bình luận
.

Bạn có biết câu trả lời không?

Hãy đăng nhập và chia sẻ nó.

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

195Bài viết196Câu trả lời
Chúng tôi sử dụng cookie để đảm bảo bạn có trải nghiệm tốt nhất trên trang web của chúng tôi.
Thêm thông tin