Reputation: 38
I have a chainlink node running in a evm testnet. I have deployed the link token and oracle contract, funded my node account with ether, created a job and a smartcontract that send a request to that job. I use the externalJobID from job definition in my Chainlink.Request. My oracle account is receieving the link fee from contract execution and request but my job is not executing. I dont see anything in my chainlink node logs.
Here is my contract code
contract Metadata is ChainlinkClient{
address private oracle;
bytes32 private jobId;
uint256 private fee;
//event variables
struct EMetaData{
address dataToken;
bytes flags;
bytes data;
address sender;
}
mapping(bytes32 => EMetaData) public metadatas;
constructor() public {
setChainlinkOracle(0x6a61789194260F0BE95a18d0116d883A4b5284ed);
setChainlinkToken(0xa38F087411e0908ad87b40Ab4D7Ca9247DE0052e);
jobId = "3a3e489f1fd145b385a18728c6947508";
fee = 0.1 * 10 ** 18; // (0.1 LINK)
}
event MetadataCreated(
address indexed dataToken,
address indexed createdBy,
bytes flags,
bytes data
);
function testCreate(
address _dataToken,
bytes memory _flags,
bytes memory _data
) public returns (bytes32 requestId){
Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
metadatas[request.id].dataToken = _dataToken;
metadatas[request.id].flags = _flags;
metadatas[request.id].data = _data;
metadatas[request.id].sender = msg.sender;
return sendChainlinkRequest(request, fee);
}
function fulfill(bytes32 _requestId, bool result) public{
require(result == true, "Validation Failed");
emit MetadataCreated(
metadatas[_requestId].dataToken,
metadatas[_requestId].sender,
metadatas[_requestId].flags,
metadatas[_requestId].data
);
}
}
}
And here is my job spec
type = "directrequest"
schemaVersion = 1
name = "Shacl validation"
contractAddress = "0x95D57363B491CF743970c640fe419541386ac8BF"
maxTaskDuration = "20s"
observationSource = """
decode_log [type="ethabidecodelog"
data="$(jobRun.logData)"
topics="$(jobRun.logTopics)"
abi="SomeContractEvent(bytes32 requestID, bytes cborPayload)"]
decode_cbor [type="cborparse"
data="$(decode_log.cborPayload)"]
ds [type="http" method=POST url="http://localhost:3000/api/v1/aquarius/assets/ddo/validate"]
ds_parse [type="jsonparse" path=""]
encode_response [type="ethabiencode"
abi="(bool data)"
data="{\\"data\\": $(ds_parse) }"]
encode_tx [type="ethabiencode"
abi="fulfillOracleRequest(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes32 data)"
data="{\\"requestId\\": $(decode_log.requestId), \\"payment\\": $(decode_log.payment), \\"callbackAddress\\": $(decode_log.callbackAddr), \\"callbackFunctionId\\": $(decode_log.callbackFunctionId), \\"expiration\\": $(decode_log.cancelExpiration), \\"data\\": $(encode_response)}"
]
submit_tx [type="ethtx" to="0x95D57363B491CF743970c640fe419541386ac8BF" data="$(encode_tx)"]
decode_log -> decode_cbor -> ds -> ds_parse -> encode_response -> encode_tx -> submit_tx
"""
externalJobID = "3a3e489f-1fd1-45b3-85a1-8728c6947508"
----------- edit 0x6a61789194260F0BE95a18d0116d883A4b5284ed was the chainlink node account
0x95D57363B491CF743970c640fe419541386ac8BF was the oracle contract address
Upvotes: 0
Views: 345
Reputation: 38
After some discussion on Chainlink discord I got some help
The problem was that I was passing my chainlink node account ou the Chainlink.Request object and the correct is to pass the oracle contract address.
Upvotes: 1
Reputation: 106
Just pulling the answer out of Discord so that others can find it more easily (as the terms node address and oracle address are regularly confused):
0x6a61789194260F0BE95a18d0116d883A4b5284ed
is the address of your Chainlink node (you can see in the key tab of the GUI), which needs to be funded with ETH in order to send transactions on-chain.
The Chainlink node listens to event logs emitted by the oracle smart contract used in the job spec, the oracle address is not the account you used to deploy it, but the address of the newly deployed oracle smart contract, make sure to follow these steps:
https://docs.chain.link/docs/fulfilling-requests/#deploy-your-own-oracle-contract
You can find the oracle contract address in Remix and the block explorer of the underlying network, that's what you need to use in your consumer contract in order to make successful requests, the LINK rewards can then be withdrawn from the oracle contract.
Upvotes: 1