With Remix
Remix IDE is an open source web and desktop application. It fosters a fast development cycle and has a rich set of plugins with intuitive GUIs.
Last updated
Remix IDE is an open source web and desktop application. It fosters a fast development cycle and has a rich set of plugins with intuitive GUIs.
Last updated
A Hello World style starter project. Deploys a smart contract with a message, and renders it in the front-end. You can change the message using the interactive panel!
This DAPP implements a "Hello World" style application that echoes a message passed to the contract to the front end. This tutorial is intended to be followed using the online IDE available at Remix IDE.
For more information on Remix and how to use it, you may find it in the Remix Documentation.
Remix IDE - an online IDE to develop smart contracts.
If you’re new to Remix, you’ll first need to activate two modules: Solidity Compiler and Deploy and Run Transactions (This should already be activated by default without you needing to search for it in the plugin manager).
Search for 'Solidity Compiler' in the plugin tab in Remix (this should be activated by default)
And activate the plugins (if they are not already activated)
The environment should be set to solidity by default
Copy/Paste the Smart contract below into the newly created file HelloWorld.sol
The first line, pragma solidity ^0.8.0
specifies that the source code is for a Solidity version greater than 0.8.0. Pragmas are common instructions for compilers about how to treat the source code (e.g., pragma once).
A contract in the sense of Solidity is a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain. The line string public message
declares a public state variable called message
of type string
. You can think of it as a single slot in a database that you can query and alter by calling functions of the code that manages the database. The keyword public automatically generates a function that allows you to access the current value of the state variable from outside of the contract. Without this keyword, other contracts have no way to access the variable.
The constructor is a special function run during the creation of the contract and cannot be called afterward. In this case, it takes a string value initMessage
, stores the value in the memory data storage area, and sets message
to that value.
The string public message
function is another public function that is similar to the constructor, taking a string as a parameter, and updating the message
variable.
Select Compiler Version to 0.8.0
Now, Compile HelloWorld.sol
/ERC20.sol
Now, we have to deploy our smart contract on f(x)Core Network. For that, we have to connect to web3, this can be done by using services like Metamask. We will be using Metamask. Please follow this tutorial to setup a Metamask Account.
Open Metamask, click the network dropdown and then click 'Add Network'. For more information on MetaMask and how to configure it to your network, you may check out this Metamask guide.
Put in a Network name (just an example):
In New RPC URL field you can add the URL:
Enter the Chain ID:
(Optional Field) Currency Symbol (just an example):
(Optional Field) Block Explorer URL:
Click Save
Copy your address from Metamask
Head over to faucet and request test FX - you will need this to pay for gas on f(x)Core. After inputting your wallet address in, select the option '100 (fxCore) FX / 24h'.
Now, let's Deploy the Smart Contract to the f(x)Core Network
Select Injected Web3 in the Environment dropdown ensure you have selected the right contract too.
Accept the connection request by clicking Next in Metamask after choosing the account
Once Metamask is connected to Remix, the ‘Deploy’ transaction would generate another metamask popup that requires transaction confirmation.
Click the EDIT button (1st picture) and then the Edit suggested gas fee (2nd picture) before editing the Max priority fee and Max fee to 4000 Gwei then click SAVE.
Click Confirm
Congratulations! You have successfully deployed HelloWorld/ERC20 Smart Contract. Now you can interact with the Smart Contract. Check the deployment status here.
After deploying the ERC20.sol
, your Remix should look something like the following:
Taking a look at the side panel in particular these sets of button functions where you can interact with the contract. By clicking on the drop down for those buttons that have a dropdown will require that you fill in those fields before clicking on the button to query/write the value of the function. For those buttons that do not have a field to fill in, you may just click on the button to read/write.
Orange buttons are writeable button functions. Blue buttons are readable button functions
Now with our custom token added, we are all ready to mint some tokens and interact with the ERC20 contract.
Clicking into the _mint (example) dropdown, you will be shown a few fields:
The fields are pretty self explanatory. Amount has to be of the type unit256 (unsigned integer), while Account has to be of the address (0x) type. Input your address and the amount you would like to mint. Do remember to add 18 0s behind. The amount value here is expressed in Wei. So if you want to mint 100 of your tokens, the field should be 100000000000000000000.
Now lets go through the rest of the buttons one by one:
Go to File Explorers, To create a new file , Name it HelloWorld.sol
Go to File Explorers, To create a new file , Name it erc20.sol
Go to Solidity Compiler
After Successful Compilation, it will show
Copy the deployed contract address and input it in Metamask. And step through with adding the custom token.
Hitting will result in a Metamask pop-up. Remember to edit the gas fields to reflect 4000 GasPrice similar to what you did before and voila, you will have minted some of your own tokens.