Skip to content

Instantly share code, notes, and snippets.

@alexroan
Last active March 25, 2021 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexroan/e1234c276aa7a6c5b845fc4bae5aa908 to your computer and use it in GitHub Desktop.
Save alexroan/e1234c276aa7a6c5b845fc4bae5aa908 to your computer and use it in GitHub Desktop.
ChainlinkHackathon/OpenLibrary/Client.sol
pragma solidity ^0.6.0;
import "https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/ChainlinkClient.sol";
contract Client is ChainlinkClient {
// where to store the last id scanned
bytes32 public last_uid;
// chainlink vars for communicating with the RFID external adapter
address private oracle;
bytes32 private jobId;
uint256 private fee;
constructor() public {
setPublicChainlinkToken();
oracle = 0x42149D794A135989319b66Dbcb770Ad36075a92e;
jobId = "785558e0bed6466b9567322cc2f4ca91";
fee = .1 * 10 ** 18; // 0.1 LINK
}
function requestData() public returns (bytes32 requestId) {
// creates the Request
Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
// Sends the request
return sendChainlinkRequestTo(oracle, req, fee);
}
function fulfill(bytes32 _requestId, bytes32 uid) public recordChainlinkFulfillment(_requestId) {
last_uid = uid;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment