Deploy Smart Contract

How to Deploy Smart Contract on Phoenix using Remix

  1. Navigate to remix.ethereum.org

  • Ensure that MetaMask is open, and you have PhoenixMainNet selected.

  • Locate the button/icon for ‘Deploy & run transactions’ on the left-hand navigation. Currently, this is the 4th icon down.

  • This will prompt a connection between Remix & Phoenix Mainnet in MetaMask. Select the wallet you want to connect.

  • Under the Environment drop down, choose Injected Web3

  1. Create a new file

  • Click on the 2nd icon/button on the left side ‘File Explorer’

  • Locate the icon/button to ‘Create New File

  • Enter the file name: SimpleStorage.sol

  1. Create the smart contract

Copy the following smart contract into the main text field on the right-hand side.

//SPDX-License-Identifier: UNLINCESED

pragma solidity >=0.4.0 <0.7.0;

contract SimpleStorage {
    uint storedData;

    function set(uint x) public {
        storedData = x;
    }

    function get() public view returns (uint) {
        return storedData;
    }
}

Let’s take a look at this contract….

SimpleStorage.sol

This smart contract has:

  • A variable storedData to store a number

  • A function get() to return the number stored at variable storedData

  • A function set() to change the number stored at variable storedData

  1. Compile the smart contract

  • Select 3rd icon/button at left side ‘Solidity compiler

It is useful to enable auto-compile

  • Click ‘Compile SimpleStorage.sol

If everything is entered correctly, you should see a green check-mark next to the 3rd icon/button with the message ‘Compilation successful’.

  1. Deploy a smart contract

To submit the transaction, you’ll need PHB tokens for gas. A form will be made available shortly to request PHB to support developer tasks.

  • Navigate back to the icon/button ‘Deploy & run transactions’

  • Since we have only one smart contract so far, it is automatically selected in the dropdown.

  • Click ‘Deploy’.

  • This will send the transaction to Metamask, requesting confirmation to create the smart contract SimpleStorage.sol

  • Click on confirm.

  • At bottom right, we can check the message: creation of SimpleStorage pending…

  • MetaMask will prompt that the transaction has been confirmed.

  • In Remix, click on the transaction line or the debug button (at the right side) to see more details of the transaction:

In this example, the transaction hash is: 0x604c0512e3bf41c3dca7a57ffe30ad0d232759b0a3cdc579a28871ede2cc0950

You can also view the example hash in Phoenix Explorer: https://explorer.phoenix.global/transactions/0x604c0512e3bf41c3dca7a57ffe30ad0d232759b0a3cdc579a28871ede2cc0950

  1. Success!

You’ve successfully deployed a smart contract on Phoenix Mainnet. Congratulations!

If you have any questions, comments, or need further assistance, join us over on our Telegram https://t.me/APEXcommunity

Last updated