useEffect(() => {
if (context.connectorName === undefined) {
if (window.web3 === undefined) {
context.setConnector("Infura");
} else {
context.setConnector("MetaMask");
}
} else {
if (context != null) {
const deployedNetwork = SupplyChainContract.networks[context.networkId];
const supplychainInstance = new context.library.eth.Contract(
SupplyChainContract.abi,
deployedNetwork && deployedNetwork.address,
)
instance = supplychainInstance
}
}
}, [context]);
useEffect(() => {
if (instance != null)
currentAccountRoles()
setTimeout(() => {
setIsLoading(false)
},3000)
}, [context, context.account])
const currentAccountRoles = async () =>{ let myRoles = await instance.methods.whoAmI().call({from: context.account})
addToLogs(myRoles)
const keys = Object.keys(myRoles)
const values = Object.values(myRoles)
let updatedRoles = []
for (var i = 6; i < 12; i++) {
updatedRoles.push({role: keys[i], isAssgin: values[i]})
}
setRoles(updatedRoles)
}
In the above context, account is giving an error. It is showing this contract object does not have address set an address first error.
Please help to us to resolve this error.