'Web3js calling authorized contract function

For my task, I have to call my contract's methods which use onlyOwner modificators, and basically has some authorizing logic. How do I call contract methods with some specific account? For example, if I have basic ERC20 token contract:

contract MyToken is ERC20 {
    function mint() external payable onlyOwner {
         _mint(msg.sender, msg.value);
    }
}

and want to call it from web3 on server side, how do I connect account to web3 client so I could call it like that:

myToken.methods.mint().send({from: 'myAccountAddress'});

How do I make web3 know that I have access to this wallet address?



Solution 1:[1]

I found the answer here dappuniversity web3js guide

Refer to Part #5 in the guide please

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yuriy Kirel