Using Remix
Last updated
Last updated
Remix is the one of the commonly used development environments for smart contracts on Ethereum. In this doc, dapp developers will learn about how to kick off their deployment of smart contracts. A “Hello World” tutorial is also included.
Remix version:0.24.1
Open the remix, an online IDE for developing and deploying Solidity contracts.
Solidity is a contract-oriented, high-level programming language created for smart contracts. The language is influenced by C++, Python, and Javascript languages and is designed to run on the Ethereum Virtual Machine (EVM).
If you are using Remix for the first time, follow these steps to activate Remix:
Open remix and select “Solidity” in the featured plugins to activate the editing interface.
Find and click on “file explorers”, create a new file or folder for yourself.
Find the “solidity compiler”, click the "compile" button, and the .sol file will be compiled and checked for errors. Fix all errors, you can proceed to the next step after the compilation is successful.
“Solidity unit testing” is also a good option, if the smart contract in solidity needs to be debugged
Step 4 To deploy the .sol file on the blockchain as a smart contract, find the "Deploy & Runtransactions" page and click the "Deploy" button.
Open remix, find and click on “file explorers”, create a new file or Folder for yourself, and start with the same steps you usually do in other IDEs. Copy the code below, paste it into a file in FILE EXPLORERS and name it “helloWorld”.
Note:
It contains the solidity version number, and the first line indicates that the source file uses a solidity version between 0.4.22 and 0.9.0.
The constructor class is a class in object-oriented programming languages such as Java and Typescript. It needs to be called when the instance is initial .
The function returns the string declared with the print method.The visibility is public, which means that everyone in the blockchain can access this string field, representing the data type returned by this function.
A more important step is the deployment of the smart contracts on Rangers Protocol. First of all, it is necessary to connect to the Web3 world and this can be done with any service such as Metamask, Brave, Portis,etc. We will use MetaMask as an example. If you don't have a MetaMask wallet account yet, you can refer to the MetaMask wallet setup doc.
In MetaMask, select the Rangers Protocol network, rangers mainnet for Rangers Protocol mainnet and robin for robin testnet. If rangers mainnet or robin is not present in the networks, please click on “add network”.
There are two methods to help you configure your network information inMetamask. The first method is automatic: enter RangersScan (or robin-rangersscan), drag to the bottom of the page, then click the button and add rangers protocol(or robin) network configuration to metamask.
The second method is to manually populate the MetaMask network configuration with the following information.
Mainnet
Network name is customized
RPC URL : https://mainnet.rangersprotocol.com/api/jsonrpc
Chain ID : 2025
Currency Symbol : RPG
Browser’s address: https://scan.rangersprotocol.com
Robin testnet
Network name is customized
RPC URL : https://robin.rangersprotocol.com/api/jsonrpc
Chain ID : 9527
Currency Symbol : RPG
Browser’s address: https://robin-rangersscan.rangersprotocol.com/
Continue and click “Save”. In order for your contract to execute smoothly on the Rangers Protocol, you will also need to get RPG test tokens from Faucet. You will need this to pay for gas on Rangers Protocol.
Next, we can deploy the smart contract on the Rangers Protocol mainnet. In DEPLOY & RUN TRANSACTIONS, select “injected Web3” as the Environment and click Deploy.
After accepting the connection request, a pop-up window will appear with a MetaMask window to confirm the "deployment" of the transaction.
Once you click on “confirm”, you have successfully deployed the “helloworld” smart contract to the Rangers Protocol.
Verify the transaction and checking the status
You can now interact with the smart contract. And you can check the deployment status in the robin testnet scan.
Congratulations on completing your first remix deployment of a smart contract!
Now, compile helloWorld.sol and on success it will show