When Metamask sends a transaction to its node provider, the node will first check that is a valid transaction and then send it across the network, to all the nodes that it knows. Then all those neighbor nodes will do the same and send that transaction to all the nodes they know, eventually reaching mining nodes that will also broadcast it and try to mine it. Once it is mined, then the miner will broadcast the block containing that transaction to all its known nodes, which in turn will do the same, until the new block is broadcasted network-wise. So, the Metamask node provider doesn't really have to be a miner node, and if it was, it wouldn't try to mine it alone, but broadcast it and then try to mine it, this way it would have a chance to get into the next block within the expected average 15 seconds.
Well, I think that my answer to your first question also answers this one. Since the transaction is broadcasted to the network, a random miner will mine the block containing that transaction, which will then be broadcasted to the network and eventually reach the node that Metamask uses, reflecting the status of the transaction.
Metamask monitors the status of your transaction. Metamask communicates with its node provider using web3js
. web3
allows you to subscribe to events, check the pending transactions (transactions in the mempool), get block headers, check if your transaction is mined and in which block, etc.
Also, if you want to see what would be the result of a transaction, let's say a transaction that calls a smart contract, but you don't want that transaction to be mined, you just want to see what would happen if it was mined, you can use web3.eth.call
function. This function sends a transaction to the provider node and the node does not broadcast it, just executes it locally and returns its result, without actually modifying the blockchain (because the transaction is not mined).
To then actually, send your transaction to be mined and broadcasted across the network, use web3.eth.sendTransaction
.
You can learn more about web3.eth.call
here: https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#call
And about web.eth.sendTransaction
here: https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#sendtransaction