DEV Community

Cover image for Run Solidity Code in Remix
Sergio Salanitri
Sergio Salanitri

Posted on

Run Solidity Code in Remix

Remix is a awersome Web Solidity Code Editor, with Remix do you not need install anything in your computer.
Using Remix you can edit, compile, deploy, test solidity contract show transaction logs, run contract methods, get github code, interact with JVM web blockchain, Metamask wallet (mainnet or testnet) and other features using Remix plugins.

image

File Explorer:
Show directoy tree with contracts codes. Keep in mind that this files save in local storage, however not shared between differents machine. I recommend create a github repo and load your code in it.

Command Bar:
Allow cahge betwwen the Remix features, such Solidity Compiler, Solidity Deploy & Run Transactions, Debug , plugins and general settings.

Solidity Editor:
Is the area where the developer write the solidity code. This to have code highlighting, intellisent, code lint and son on.

Transactions Logs:
Show the compiler, deploy, test, run contract functions, connect with blockchain provider etc.

General Settings:
Allow to develop set the editor settings.

Solidity Compiler:

image

The solidity compiler version must be compatible with #pragma definition in the code.

Where run the Compiler buttom, Remix compile the contract and in succesful case generate the ABI and the bycode associated with the contract.

image

The Application Binary Interface is the interface that expose the compiler contact. This is used to interact with the contract from out of chain.

Deploy the contract

Remix allow deploy the contract into JVM local blockchain, inject into external wallet such Metamask or external Web3 provider. Web3 is the protocol used to interact with external chain clients.

image

1- Deploy the contract in selected provider, in this case in JVM provider.
2- If the deploy is succesful Remix show button relationship with the contract public functions. The buttons color indicate if the operaction transaction save data (orange) or get data (blue) to or form chain.
3- We can view in transaction panel the information about the storage function.
4- Button to invoke retrieve function.
5- Beside we can view the transaction log from retrieve function.

Deploy the contract with Metamask

Metamask is a wallet implemented how Chrome extension, allow to developers connect to Ethereum blockchain.
In the case of Remix we can select Metamask provider using the Remix Enviroment combo box.
Previously you must install the Metamask extension and create a a wallet.

Now, we deploy and run the contract using Metamask.
Metamask allow connect to different blockchains, testnet , mainnet and other networks using RPC protocol. In this example with use the Rinkeby testnet network.
Before use it, we must transfer some fake Ethers to te wallet using th Rinkeby Faucet web page.

First in all you select one account address in your wallet.

image

Second , you use this address en Rinkey Faucet web page, follow the intructions to transfer some fake ethers to you address.

image

In this case when you run some transaction the Metamask extension popup a authorization message, if you click OK; the transation is send to Rinkeby network and several seconds later the transaction is confirmed.

If you enter to the Rinkeby account , you show that the account balance decrease en little ETH, this difference is due to the transaction gas fee.

References
Remix IDE: http://remix.ethereum.org/
Solidity ABI specification: https://bit.ly/3Ai3qof
Metamask: https://metamask.io/

Top comments (0)