Decentralized Programmer: Part 3 Remix IDE + Ganache-CLI

in #ethereum7 years ago (edited)

Remix IDE

Remix IDE is a full featured Solidity smart contract IDE (Integrated Development Environment). It can be used to:

  • Develop smart contracts (remix integrates a solidity editor).
  • Debug a smart contract’s execution.
  • Access the state and properties of already deployed smart contract.
  • Debug already committed transaction.
  • Analyze solidity code to reduce coding mistakes and to enforce best practices.

Tutorial

  1. Go to
  2. Click on the + icon in top left to create a new file. Name it FirstContract.sol
  3. Copy and a paste a sample smart contract from below:
pragma solidity ^0.4.0;

contract FirstContract {
    string storedName;

    function set(string x) public {
        storedName = x;
    }

    function get() public constant returns (string) {
        return storedName;
    }
}

The smart contract is very simple, it lets user to save and retrieve any string (set of characters).

4.Compile
Click on the Compile on top to open Compiling tab, and then click on Start to compile.

If you see the name of your contract in a green it means that everything went well.

  1. Deployment and running the contract
    At first let's make sure your Ganache-CLI environment is up and runnig. Go to terminal and type: ganache-cli
    to start the testing environment.

In Remix IDE go to a Run tab

Make sure to select the Web3 provider as an environment.

Now you can click on the Create button. You should be able to see two things:
Successful debug message

Interactive tab with two buttons to work with your contract:

  1. Interacting with contract
    Type your name into a text field next to set button. Make sure you use quotes for example: "Janusz Chudzynski" and click on the set button. What it does is creating new transaction that is sent and saved into your test Ethereum blockchain.

The debug console should display updated information about transaction.

Now to test if it worked click on the 'get' button. You should see the following:

Documentation

https://remix.readthedocs.io/en/latest/

Link

http://remix.ethereum.org/

Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.034
BTC 99341.76
ETH 3285.44
USDT 1.00
SBD 3.05