Get the owner address of the contract

Hi guys,
I need to get the owner address but I don’t figure out how to do it with Moralis, any idea ?

how could you do that on chain? it can depend from contract to contract, if the contract has a function named getOwner then you can call that function

For example I’ve got a function :

    function addVoter(address _addr) external onlyOwner {}

onlyOwner come from OpenZeppelin and when I deploy my contract the first account from my Metamask is considering as the owner, how it works ?

what do you mean with how it works?

How Morelis know my first account is the owner ? Or maybe I don’t understand something

Moralis doesn’t know that, the contract will make that check and will allow only the owner to call that function.

I’ve still work to do to clearly understand thx cryptokid