Hey,
Im still learning how to write my smart contracts and have got stuck with a weird problem i dont fully understand
I have a function in a contract that looks like this
function getOwner(uint deviceId) public view returns (address) {
return deviceToOwner[deviceId];
}
It works in the test case when I test it like so
const owner = await deviceFactoryInstance.getOwner(deviceId);
expect(owner).to.equal(accounts[0]);
However, when I try to fetch this from the client using web3.js I get an error
const index = 0
const owner = await deviceFactory.methods.getOwner(index).call();
Could anyone help explain what im doing wrong?
Nov 23, 2021, 2:35 PM
any help on this is appreciated, i dont have bnb to send if anyone helps though (in all honesty)
nvm it worked, deleted my old contracts and redeployed… Note to self: battle test before deploying to higher networks. This thing is still glitchy
Nov 23, 2021, 3:33 PM