I am trying to call an onlyOwner predicated function. With the address in metamask that I deployed from and I have verified that IS the owner.
Can you share small parts of code (reset countdown function for example)?
How did you get the owner when you clicked on âconsole log ownerâ button? (was a contract call)
The expectation would be to work what you did, I donât know why it didnât work.
Sure,
In Solidity:
function resetRTSCountdown() public onlyOwner {
returnToSenderCountdownBeginDateTime = block.timestamp;
}
and In JS:
const resetCountdown = () => {
aetokenContract.methods.resetRTSCountdown().call();
}
<button onClick={resetCountdown}>reset countdown (admin only)</button>
How Iâm retrieving the owner
const getOwner = () => {
console.log(aetokenContract.methods.owner().call());
}
Try:
const resetCountdown = () => {
aetokenContract.methods.resetRTSCountdown().send({from: ethereum.selectedAddress });
}
Where does âethereumâ come from is a web3? so something like web3.ethereum.selectedAddress?
that syntax usually works, but you can use any other syntax that gets you current eth address.