Challenge - 5 Problems
Chainlink Oracle Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Chainlink oracle request event?
Consider the following Solidity event emitted after a Chainlink oracle request is sent. What will be the output in the transaction logs when the request is made?
Blockchain / Solidity
event ChainlinkRequested(bytes32 indexed requestId);
function requestData() public returns (bytes32 requestId) {
requestId = sendChainlinkRequestTo(oracle, jobId, payment);
emit ChainlinkRequested(requestId);
}Attempts:
2 left
💡 Hint
Remember that events declared outside functions can be emitted inside functions.
✗ Incorrect
The event ChainlinkRequested is declared correctly and emitted with the requestId. This will appear in the transaction logs as an event with the requestId indexed.
🧠 Conceptual
intermediate1:30remaining
Which Chainlink component is responsible for fetching off-chain data?
In the Chainlink architecture, which component actually retrieves data from outside the blockchain?
Attempts:
2 left
💡 Hint
Think about which part connects to the real world outside the blockchain.
✗ Incorrect
Chainlink Oracle Nodes are off-chain services that fetch data from external APIs and deliver it to smart contracts.
🔧 Debug
advanced2:30remaining
Why does this Chainlink callback function fail to update the state?
Given the following Solidity code snippet, why does the state variable not update after the oracle response?
Blockchain / Solidity
bytes32 public data;
function fulfill(bytes32 _requestId, bytes32 _data) external recordChainlinkFulfillment(_requestId) {
data = _data;
}
function requestData() public {
Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
sendChainlinkRequestTo(oracle, req, payment);
}Attempts:
2 left
💡 Hint
Oracle calls to fulfill functions require a specific visibility.
✗ Incorrect
Chainlink oracle nodes call the fulfill function externally, so it must be marked external. If it is public, the call will fail.
📝 Syntax
advanced2:00remaining
Which option correctly initializes a Chainlink.Request struct?
Select the correct way to initialize a Chainlink.Request struct in Solidity for a job with jobId and callback function fulfill.
Attempts:
2 left
💡 Hint
Look for the correct use of memory keyword and selector syntax.
✗ Incorrect
The buildChainlinkRequest function returns a properly initialized Chainlink.Request struct with memory keyword and the fulfill function selector.
🚀 Application
expert3:00remaining
What is the final value of `result` after this Chainlink oracle response?
Given the following Solidity contract snippet, what will be the value of the public variable `result` after the oracle calls fulfill with _data = 42?
Blockchain / Solidity
uint256 public result;
function requestData() public returns (bytes32 requestId) {
Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
requestId = sendChainlinkRequestTo(oracle, req, payment);
}
function fulfill(bytes32 _requestId, uint256 _data) public recordChainlinkFulfillment(_requestId) {
result = _data * 2;
}Attempts:
2 left
💡 Hint
Check how the fulfill function processes the _data parameter.
✗ Incorrect
The fulfill function doubles the _data value and assigns it to result, so 42 * 2 = 84.