Blockchain By Example
上QQ阅读APP看书,第一时间看更新

Deploying the contract

If your RSK node is synchronized with the network, we can easily deploy our contract using Remix. Remix is a browser-based IDE that enables developers to compile and deploy Solidity smart contracts into the blockchain. Further instructions and details about Remix will be presented in Chapter 4Peer-to-Peer Auctions in Ethereum and Chapter 5, Tontine Game with Truffle and Drizzle.

We need to connect Remix to our running RSK node by performing the following steps:

  1. Open the Remix IDE by visiting http://remix.ethereum.org.
  2. In the Run tab (right menu), select Environment | Web3 provider.
  3. In the popup, define http://localhost:4444 as your Web3 provider endpoint.

Once connected, paste the contract code into Remix's code section and, in the right-hand panel, press the Deploy button to send a transaction that deploys the selected contract. RSK VM is based on Ethereum VM, therefore the cost of deploying and interacting with the smart contract is calculated in gas. Nevertheless, the gas will be paid in SBTC.

While transferring the contract to the RSK network, Remix will display important information in the console located at the bottom of the main section.

Due to breaking changes introduced with the newer Solidity compiler +V0.5 (used by default), you have to downgrade the Remix's compiler version to a prior version (for example  version   0.4.25+ )  in order to run without error the presented contract. The process to achieve that is presented in the official documentation ( https://remix.readthedocs.io/en/latest/settings_tab.html).