1

Hello. I am doing online problems and learning to code in solidity. I found a page with the following problem, however it doesn't have answers to the problems. This is the prompt:

"This project is focused on calling other smart contracts and sending ether. Your job is to interact with a deployed contract called Oracle which has the following interface:

interface IOracle {
    /// @notice Receives a student's stringID and marks it as being submitted, reverts if a value not equal to 1 Wei is sent
    /// @param netID a lowercase string of the student's netID, NO WHITESPACES
    /// @return bool indictating success of operation
    function sendStringID(string memory stringID) external payable returns (bool);
}

In essence, your job will be to create a smart contract which calls sendStringID with your stringID as the argument and 1 Wei attached with the function call.

Oracle Contract Address (Goerli Testnet): ... "

I am confused on how to do this, and want to make it as simple as possible.

Please explain to me how to write this seemingly short code using .call() within the function. Additionally, I am rusty on concepts on OOP and am not sure what state variables I should initialize and if/how a constructor would be used. Thank you so much in advance. I have hit a little bit of a roadblock and I think this solution would greatly benefit my learning. I have run out of Goerli Eth, thus I can't afford making so many errors and having one correct answer would allow me to be more cost efficient.

1
  • Please, provide what you have done, and any description of the error message. This site is for resolving technical issues, we can answer your doubts, but we shouldn't make your homework. If you haven't understood the lesson probably it is better to ask the about the topic you don't understand.
    – Ismael
    Commented Mar 13, 2023 at 5:02

1 Answer 1

2

This is the best time to learn about interfaces and contract calling another contract. in this case you can do this:

contract Solution {
   function Solve(address _target) external payable{
   _target.call{value:1}(abi.encodePacked("sendStringID()","thestudentid");
//send one wei while caling the function.
}
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.