I'm trying to learn Soliity and started with a basic api.
I pass the parameters of the function (from here I got the format of the parameters https://market.link/nodes/5fcd7b71-33aa-4679-bc70-75d3ebe01c04/integrations)
after compiling, deploying and anchoring the contract with LINK, it sent the parameters with the Team Name and the date, but data always remains in 0x00000000000. Any help is welcome, thanks
pragma solidity ^0.8.7;
import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";
/**
* Request testnet LINK and ETH here: https://faucets.chain.link/
* Find information on LINK Token Contracts and get the latest ETH and LINK faucets here: https://docs.chain.link/docs/link-token-contracts/
*/
/**
* THIS IS AN EXAMPLE CONTRACT WHICH USES HARDCODED VALUES FOR CLARITY.
* PLEASE DO NOT USE THIS CODE IN PRODUCTION.
*/
contract sportContract is ChainlinkClient {
using Chainlink for Chainlink.Request;
bytes32 public data;
address private oracle;
bytes32 private jobId;
uint256 private fee;
/**
* Network: Kovan
* Oracle:
* Name: Chainlink DevRel - Kovan
* Address: 0xfF07C97631Ff3bAb5e5e5660Cdf47AdEd8D4d4Fd
* Job:
* Name: SportsDataIO
* ID: 9abb342e5a1d41c6b72941a3064cf55f
* Fee: 0.1 LINK
*/
constructor() {
setPublicChainlinkToken();
// https://market.link/data-providers/d66c1ec8-2504-4696-ab22-6825044049f7/integrations
oracle = 0xfF07C97631Ff3bAb5e5e5660Cdf47AdEd8D4d4Fd;
jobId = "9abb342e5a1d41c6b72941a3064cf55f";
fee = 0.1 * 10 ** 18; // (Varies by network and job)
}
// Initial Request
function requestData(string memory _date, string memory _team) public returns (bytes32 requestId) {
Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
req.add("date", _date);
req.add("teamName", _team);
return sendChainlinkRequestTo(oracle, req, fee);
}
// Callback Function
function fulfill(bytes32 _requestId, bytes32 _data) public recordChainlinkFulfillment(_requestId) {
data = _data;
}
// function withdrawLink() external {} - Implement a withdraw function to avoid locking your LINK in the contract
}