You can easily export your MetaMask account private key when it’s required for a Smart Contract function. I know you’ve heard it a hundred times, but once more won’t hurt: Be careful to keep access to the file secure so no one else can get access to your wallet.
To do so log into your MetaMask account and click on: Account options<Account Details<Export Private Key>
Enter your password on command to prove that you are you:
Copy your Key: Click . <Done>