以太坊的remix下執行環境的三種選項

參考自
Remix has 3 different environment options that can be used to deploy/test Solidity contracts: JavaScript VM, Injected Web3, and Web3 Provider. This option can be changed under the Environment drop down under the Run tab.
這裡寫圖片描述

JavaScript VM:

This is Remix’s own internal sandbox. It does not connect to MainNet, TestNet, or any private network. It’s an in-memory blockchain that can be used for simple testing and quick mining.

Injected Web3:

This is the option to use for the browser plugin (MetaMask). Here, you are telling Remix to defer all control of the blockchain integration to the MetaMask plugin. At this point, MetaMask controls which network you are connecting to.

In the plugin, you can connect to MainNet, Ropsten, Rinkeby, etc through Infura’s node network. In this case, you’re not running a node locally. MetaMask also has a localhost option where you can run your own node locally and MetaMask will send all transactions to it (this local network can be a private network using any node client or you can use a test blockchain like TestRPC).

Web3 Provider:

This allows you to enter a URL in Remix to connect to the blockchain. The most common setup here is to be running a local node and connecting to it through it’s IP/port.

This is pretty much the same as using MetaMask’s localhost option, but you’re just cutting the plugin out of being the middleman. Just like option #2, the network your connected to depends on how you’ve configured your local node (it can be main, test, private, etc.).