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 open two new windows: 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 opens up the deployment process in a separate window.
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://superblocks-browser.
It is possible to change the network by clicking the Select a Network button in the left side menu, which value defaults to Browser. The available networks are Browser, Custom, Rinkeby, Ropsten, Kovan, Infuranet, 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 left side of the screen. 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 Superblocks Lab 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 the compile step fails, the deployment process returns the following error:
- "The contract could apparently not be compiled."
- When no external providers are found due to the browser extension not being installed or in case it is installed but disabled, the deploy step will fail with the following error:
- "External provider not found."
- When the currently selected network is different from the network selected in the external provider, the following error will appear:
- "The Metamask network does not match the Superblocks Lab network. Check so that you have the same network chosen in Metamask as in Superblocks Lab, then try again."
- When the external provider is found but the account wallet is either locked or inaccessible, the following error will occur:
- "External account not found. Metamask unlocked?"
- When a transaction is rejected or another unknown error happens with the external provider, the following error message will appear:
- "Could not deploy contract using an external provider."