I am using wagmi's useContractRead to fetch data from my solidity contract, now problem is that in that contract I use msg.sender
to access the data about sender. My solidity code looks like this:
function getInfo() public view returns (bool, uint8, address) {
return (
data[msg.sender].ts != 0,
data[msg.sender].info,
msg.sender
);
}
and by default useContractRead is returning
[false, 0, '0x0000000000000000000000000000000000000000']
, bear in mind if i call this exact same function with useContract
I need to pass signer, otherwise it throws an error (using metamask).
My useContractRead
looks like this
const { isConnected, address } = useAccount();
useContractRead({
abi: currentEnvContract.abi,
address: currentEnvContract.address,
functionName: 'getInfo',
enabled: isConnected,
// overrides: { from: '0x765d5A82bba93F44fa3514d6dce9f7351dF1b7fA' },
onSuccess: (data) => {
console.log(data);
},
});
as you see I have overrides.from
commented, and that address does not belong to me, it is random address I found on goerli etherscan. and if I uncomment it the contract will return
[false, 0, '0x765d5A82bba93F44fa3514d6dce9f7351dF1b7fA']
why does this happen? I should not be able to use this address. and if this is wrong, is there way to send my current connected address as msg.from
to my solidity contract.