To deploy a contract on my local set up I use truffle. The development network is running by Ganache. Also sending data on to the network from app A is no problem (using truffle/truffle-contract packages). I start this app in the same working directory as I compile and migrate the contracts
However, when I have another app connected to this network and attempt to retrieve data I run into issues. This does not use anything of truffle, only web3js.
I retrieve data as follows:
let contractInstance = new web3.eth.Contract(abi, result.contractHashes)
if (!contractInstance) handleError('Could not find contract instance... Shutting down')
for (let i in result) {
let internalId = result[i]._id
contractInstance.methods.getStartDate(internalId).call(function(error, result) {
if (error) handleFatalError(error, mongoClient) // This error is triggered
console.log(result)
})
}
This always returns me:
Error: This contract object doesn't have address set yet, please set an address first.
From 48609913 I understand this occurs when you forget the mentioned step as described, however, I am not creating a new contract, I am simply referencing to a countract already existing in the network. It does not make sense to me if I reference to a contract by its address it does not know the contract address? Based on this article I tried to use the step missing (trail and error) following web3 options address, but same error message.
Also using
call().then(....)
or
call({ from: result.contractHashes }, function(error, result) {....})
did not work. I am pretty clueless and can not make sense of the reasoning of the issue. I hope someone with more experience among you people can.
result.contractHashes
? – user94559