I am trying to fetch close prices of a property deployed on a server running on a chainlink node. Here's what a snippet from my contract (RealEstateAPIConsumer.sol) looks like :
function returnClosePrice(string memory _name) public {
Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.myCallback.selector);
request.add("name", _name);
request.add("copyPath", "closePrice");
receipts[sendChainlinkRequestTo(oracle, request, fee)] = stringToBytes32(_name);
}
function myCallback(bytes32 _requestId, uint256 _price) public recordChainlinkFulfillment(_requestId){
tokenHash = receipts[_requestId];
delete receipts[_requestId];
currentRealEstatePrice[tokenHash] = _price;
latestRequestId = _requestId;
price = _price;
}
The contract is deployed on a kovan infura node. When I invoke the truffle console with:
await instance.returnClosePrice("Mannat")
my terminal becomes unresponsive and there's no response coming from the node.
Here's what my migration file looks like:
var RealEstateAPIConsumer = artifacts.require('RealEstateAPIConsumer')
module.exports = function(deployer){
deployer.deploy(RealEstateAPIConsumer)
}
Here's what my truffle-config looks like:
require('dotenv').config()
const HDWalletProvider = require('@truffle/hdwallet-provider');
const kovanUrl = process.env.KOVAN_URL;
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
const NonceTrackerSubprovider = require("web3-provider-engine/subproviders/nonce-tracker")
module.exports = {
networks: {
development: {
host: "localhost",
port: 7545,
network_id: "5777"
},
kovan: {
provider: function() {
var wallet = new HDWalletProvider(mnemonic, kovanUrl);
var nonceTracker = new NonceTrackerSubprovider()
wallet.engine._providers.unshift(nonceTracker)
nonceTracker.setEngine(wallet.engine)
return wallet
},
network_id: 42
}
},
mocha: {
},
compilers: {
solc: {
version: "0.6.6",
},
},
};
Can anyone throw some light into the issue as to why it might be happening (this works fine on Remix. Only truffle console seems to cause issues) ?