Hey everyone, I’m stuck with my smart contract that’s supposed to get data from an external API using Chainlink oracles. It works fine on Ethereum Kovan, but I’m having trouble on Avalanche Fuji testnet.
I’ve tried using these settings:
- Avalanche Testnet
- Job: Get > Uint256
- Oracle: 0xCC80934EAf22b2C8dBf7A69e8E0D356a7CAc5754
- Job ID: 5ca4fa9b2d64462290abfbda84e38cf4
- Fee: 0.1 LINK
The weird thing is, on Kovan I get both chainlinkRequested and chainlinkFulfilled events. But on Fuji, I only see chainlinkRequested. It looks like the oracle isn’t sending the data back to trigger the chainlinkFulfilled event.
Here’s a simplified version of my code:
contract APIDataFetcher is ChainlinkClient {
uint256 public dataResult;
address private dataOracle;
bytes32 private dataJobId;
uint256 private dataFee;
constructor() {
setChainlinkToken(0x0b9d5D9136855f6FEc3c0993feE6E9CE8a297846);
dataOracle = 0xCC80934EAf22b2C8dBf7A69e8E0D356a7CAc5754;
dataJobId = "5ca4fa9b2d64462290abfbda84e38cf4";
dataFee = 0.1 * 10 ** 18;
}
function fetchExternalData() public returns (bytes32 requestId) {
Chainlink.Request memory request = buildChainlinkRequest(dataJobId, address(this), this.fulfillData.selector);
request.add("get", "https://api.example.com/data");
request.add("path", "result.value");
return sendChainlinkRequestTo(dataOracle, request, dataFee);
}
function fulfillData(bytes32 _requestId, uint256 _result) public recordChainlinkFulfillment(_requestId) {
dataResult = _result;
}
}
Any ideas on how to fix this or what I might be doing wrong? Thanks!
Having worked extensively with Chainlink oracles across different networks, I can offer some insights. The issue likely stems from network-specific configurations. Avalanche Fuji requires different oracle addresses and job IDs compared to Ethereum testnets. I’d suggest verifying the Chainlink documentation for Fuji-specific details.
Also, ensure your contract is properly funded with LINK tokens on Fuji. The testnet faucet should provide enough for testing. If the problem persists, try debugging with events. Add custom events in your contract to log each step of the request process. This can help pinpoint where exactly the execution stops.
Lastly, consider the API endpoint you’re querying. Some external APIs might have restrictions or rate limits that could affect oracle responses on different networks. Double-check that the API is accessible and responding correctly when called from Fuji.
I’ve faced a similar issue when working with Chainlink on Avalanche Fuji. The problem might be related to the oracle contract you’re using. The address you provided (0xCC80934EAf22b2C8dBf7A69e8E0D356a7CAc5754) is actually for Ethereum’s Kovan testnet, not Avalanche Fuji.
For Avalanche Fuji, try using this oracle address instead: 0x31D3A7711a74b4Ec847cC68A5C34dCE083B683e9
Also, double-check your LINK token address. The correct one for Fuji is: 0x0b9d5D9136855f6FEc3c0993feE6E9CE8a297846
Make sure you’ve funded your contract with enough LINK tokens on the Fuji network. Sometimes, the transaction might fail silently if there’s not enough LINK to pay for the oracle request.
Lastly, verify that the Job ID is correct for Fuji. You might need to check the Chainlink documentation or their Discord for the most up-to-date Job IDs on Avalanche Fuji.
If you’ve confirmed all these and it’s still not working, try increasing the gas limit for your transactions. Avalanche can sometimes require higher gas limits than Ethereum networks.
hey mate, i’ve run into this before. check ur oracle address - it’s wrong for fuji. use 0x31D3A7711a74b4Ec847cC68A5C34dCE083B683e9 instead. also make sure u’ve got enough LINK in ur contract. sometimes it fails quietly if ur short. good luck!