Remix

From BitcoinWiki
(Redirected from Browser Solidity)

This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search

Remix, previously known as Browser Solidity, is a web browser based IDE that allows you to write Solidity smart contracts, then deploy and run the smart contract.

You can run Remix from your web browser by navigating to https://ethereum.github.io/browser-solidity/, or by installing and running in on your local computer.


Local Installation[edit]

Instead of running Remix from https://ethereum.github.io/browser-solidity/, you can download the latest package from https://github.com/ethereum/browser-solidity . You will have to switch to the branch gh-pages. Download the .zip file with a name similar to remix-0f851e3.zip into a directory on your computer. Unzip the .zip file. Load index.html in your browser.

The advantage of running Remix from your local computer is that it can communicate with an Ethereum node client running on your local machine via the Ethereum JSON-RPC API. You can then execute your smart contracts in Remix while connected to your local development blockchain, the Testnet blockchain, or the Mainnet blockchain.

The Remix Screen[edit]

Whether you are running Remix from it's website, or from your local installation, you should see a screen resembling the one below. 1024px


Taking Remix For A Run[edit]

Sample Source Code[edit]

Following is the source code for a simple example that you can copy and paste into the left section of your Remix screen.

<syntaxhighlight lang="javascript" line='line'> pragma solidity ^0.4.8;

contract Hello {

   // A string variable
   string public greeting;
   
   // Events that gets logged on the blockchain
   event GreetingChanged(string _greeting);
   
   // The function with the same name as the class is a constructor
   function Hello(string _greeting) {
       greeting = _greeting;
   }
   // Change the greeting message
   function setGreeting(string _greeting) {
       greeting = _greeting;
       
       // Log an event that the greeting message has been updated
       GreetingChanged(_greeting);
   }
   // Get the greeting message
   function greet() constant returns (string _greeting) {
      greeting = greeting;
   }

} </syntaxhighlight>


Deploy Sample Source Code[edit]

On the right hand side, enter <code>"Hello, World!"</code> into the input box to the right of the Create button. Click on the Create button and your contract will be deployed to the JavaScript EVM. The constructor in the source code will be executed with the <code>"Hello, World!"</code> string passed as the parameter.

Your screen should resemble:

1024px

The first light blue block with the heading greeting shows that after you deployed the contract, the <code>greeting</code> variable has been set to <code>"Hello, World!"</code>.

The second light blue block with the heading greet shows the results of executing the <code>greet()</code> function.


Execute Sample Source Code Function[edit]

Scroll down the right hand side of the page and enter <code>"Hello from BokkyPooBah!"</code> into the input box to the right of setGreeting. Click on the setGreeting button and the <code>setGreeting(...)</code> function will be executed with the <code>"Hello from BokkyPooBah!"</code> string passed as the parameter. You will also see the <code>GreetingChanged</code> event logged in the results.

1024px

If you now click on the greeting and greet button, the new value of the <code>greeting</code> will be displayed as shown below:

1024px


Some Remix Options[edit]

The Remix Settings Tab[edit]

The following screenprint shows the Remix Settings tab. Use this section to change the Solidity version and whether to enable or disable optimisation. You can also switch off the Auto Compile.

512px


The Remix Transactions Tab[edit]

The following screenprint shows the Remix Transactions tab. Use this section to select from one of your Accounts, specify the amount of Gas supplied for the transaction and the amount of ethers to send from your specified account with the transaction.

512px


The Remix Environment Tab[edit]

The following screenprint shows the Remix Environment tab. The default setting is to deploy and run your smart contract in the local JavaScript EVM. You can also select Web3 and connect to your local node via JSON-RPC.

512px

Source[edit]

http://theethereum.wiki/

See Also on BitcoinWiki[edit]