omchain
Search
K

Remix

You can visit https://remix.ethereum.org/ to start using Remix IDE to develop smart contracts.
Remix IDE layout
  • Blue area: You can switch between workspace, compiler, contract deployer and debugger.
  • Red area: Current workspace
  • Orange area: Create a new file or folder, or pull files from Github or upload from your computer
  • Green area: The space where you will write your codes
  • Yellow area: Terminal of the Remix IDE
Now we can click on the file icon shown on the orange area to create a new contract and name it SimpleStorage.solRemix will automatically open the file on the green area. Then we can copy and paste our previous example to the file.
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.9.0;
contract SimpleStorage {
uint storedData;
function set(uint x) public {
storedData = x;
}
function get() public view returns (uint) {
return storedData;
}
}
After that we click on the compiler and click on Compile SimpleStorage.sol
1st step
2nd step

Deploying a compiled contract

We can click on the third option from the left panel.
1st step
Then we will see the options for the compiler. Now we need to connect our wallet to Remix in order to sign the transaction and deploy our contract on Jupiter. However, it is a good practice to first deploy the transaction on our browser to test whether everything is working as intended or not. In order to do that, simply click on Deploy button.
2nd Step
If there is no error deploying our contract, it will be deployed on our local device and we will see a success message on the terminal.
Deployed contract
Now we click on the contract's name from the bottom left and see what we can do with our contract.
3rd step
Now we can click on the arrow icon to see our function and use it. Now determine a number x that will be assigned to our value x on the chain. We can use 9102020 as an example. Now all we have to do is to click the transact button.
4th step
Upon clicking on transact, we can see that the message on the terminal has changed and updated with our latest transaction's information. This means that our transaction was successful and our value is set. Now we can use the get function to read the value we set for x. All we have to do is to click the get button.
5th step
That's it. Now our contract can store a number on blockchain and we can read that value from our contract. If storing a number on the blockchain is not that interesting for you, then you can take a look at the example ERC20 token contract below.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract SampleToken is ERC20, Ownable {
constructor() ERC20("SampleToken", "STK") {
_mint(msg.sender, 100 * 10 ** decimals());
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
}