In order to have a particular contract available on any network, be it the locally available network or a public network, it is necessary to run the deployment process.
Taking as example the Hello World template, open the HelloWorld.sol contract by clicking on it in the Files hierarchy. While in the editor, click the Deploy button, presented at the editor top bar as the third button (the play icon). Regardless of having run the compile step for the current contract on a previous step, running the Deploy action will incur in two sequential operations: one for executing the compilation process and another one for deployment.
The deployment window shows all the steps taken from the compilation, account settings, signing, until the step which is the actual contract deployment transaction. After that, the deployment process waits for the transaction to be mined and, as a last step, returns the contract address.
Alternatively, as with any action in the context of contracts, it is possible to access the Deploy button by clicking the arrow next to the HelloWorld.sol contract to expand the item. Clicking the Deploy button directly from the left side menu also triggers the deployment process.
A contract will only be recompiled if one of the following events happen:
- a given source file hasn't been compiled yet
- a file has been updated
Alternatively, for recompiling a single source file that has not been changed, a simple method is to touch the file by saving it again. Similarly, project redeployment only happens when one of the following events happen:
- a given compiled contract hasn't been deployed yet
- a contract binary has been changed
Select a Network
By default, contracts are deployed to the in-browser network, which can be observed by the endpoint information shown during output and also represented in the status bar, at the right bottom of the screen: http://ethereum-studio-browser.
It is possible to change the network by clicking the Select a Network button in the top menu bar, which value defaults to Browser. The available networks are Browser, Custom, Rinkeby, Ropsten, Kovan, Mainnet.
The custom network enables deployment to a private node running locally, as long as it is accessible via localhost hostname and port 8545. The public networks take advantage of Infura (https://infura.io/) services for accessing the public Ethereum networks.
Following the Hello World template as an example, deploying the HelloWorld.sol contract to the Rinkeby test network, or any other public network requires an external provider. The MetaMask (https://metamask.io/) browser extension is supported.
With the external provider in place, deploying to Rinkeby is as simple as changing the network setting to Rinkeby using the Select a Network button, on the top menu bar. After that, run the deploy action again by clicking the Deploy button from the editor top bar. The external provider will be called to confirm the transaction. Once the external provider finishes intermediation, control will go back to Ethereum Studio and the deployment process will continue, the same way as with any other network.
Gas Limit and Gas Price used for deployment can be set in the Preferences window, located at the top right corner of the screen. Leaving any value empty and clicking the Save button resets the entry to the default state.
Below is a list of common errors that occur when trying to deploy a contract:
- When no external providers are found, the deploy step will fail with the following error: "External provider not found.".
- When the network is set to a different network defined on the external provider, the following error will appear: "The Metamask network does not match the Ethereum Studio network. Check so that you have the same network chosen in Metamask as in Ethereum Studio, then try again."
- When the external provider is found but the account wallet is locked or inaccessible, the following error will occur: "External account not found. Metamask unlocked?"
- When a transaction rejection or other unknown error returns from the external provider, the following error message will appear: "Could not deploy contract using external provider."