Developers Forum for XinFin XDC Network

Vinn V
Vinn V

Posted on

Setup Remix - Become XDC Blockchain Developer | Learn to Execute Solidity Smart Contract with XDC-Remix.

XinFin (XDC) Remix is a Solidity IDE that’s used to write, compile, and debug Solidity code. Solidity is a high-level, contract-oriented programming language for writing smart contracts. It was influenced by popular languages such as C++, Python, and JavaScript.

IDE stands for Integrated Development Environment and is an application with a set of tools designed to help programmers execute different tasks related to software development such as writing, compiling, executing, and debugging code.

Here we will write a simple Smart Contract, compile, then deploy it using XDCPay Apothem Network.

Smart Contract Creation
Here we are using a simple Smart Contract which displays the greetings: “Hello World!”

In Remix, create a new file named Test.sol. To create a file, click on the Icon of the File at the top left corner of the page:

Image description

After clicking the Icon, this will ask for the filename of the new contract. Just input Test.sol like this:

Image description

After the file is created, add the following code to the code editor:

// compiler version must be greater than or equal to 0.8.10 and less than 0.9.0

pragma solidity ^0.8.10;

contract HelloWorld {

string public greet = “Hello World!”;

}
Enter fullscreen mode Exit fullscreen mode

Here we have defined the function greet().

Compiling and Deploying Contracts
After writing the Smart Contract, First we need to compile the code to check if there are errors or warnings. If there are no errors, the Smart Contract is ready to be deployed.

Compiling a Contract
To compile a Smart Contract, go to the “SOLIDITY COMPILER” Tab and select the compiler version and select the appropriate version that is suitable to your Solidity version. Here we are using Solidity version 0.8.10

You can refer to the screenshot below to find the tab and the settings:

Image description

Now, click on the Compile Test.sol button, a success message or a list of errors will show below:

Image description

Here you can see, Smart Contract has been successfully compiled. You can now deploy the code.

Contract Deployment
After successfully compiling your contract, you can now deploy it. Go to the “DEPLOY & RUN TRANSACTIONS” Tab.

Image description

Now Deploy the Contract with the “JavaScript VM”. Select “JavaScript VM” from the dropdown menu.

Deploying the Smart Contract using Injected Web3

Here we will use the XDCPay to Deploy the contract. We select the “Injected Web3” for the Environment and leave the other options to default.

You can refer to the Guide article of Using XinFin’s Apothem Network / Sandbox Network to test blockchain applications.

Now click on the Deploy button to deploy the contract. The XDCPay window will appear for the confirmation of the Deployment.

While Deployment, you need Testnet XDC for the Contract Creation Fees. You can get the Testnet XDC from the XDC Faucet

Image description

After the contract is Deployed, the instance will show up at the bottom of the tab and you will be able to access the functions and in the Terminal, you can check the Contract creation and transaction details.

Image description

Once you deploy your Contract on XDC Network (On Testnet i.e on the Apothem Network), you can Verify it on XDC Explorer.

Simple steps to Verify your Deployed Smart Contract:

Step1: Copy your Contract address from the XinFin Remix and paste it on XDC Explorer.

Image description

If you have deployed your Smart Contract on Testnet then visit:

XDC Network — XinFinScan Explorer:https://explorer.apothem.network/

XDC Network — BlocksScan Explorer: https://apothem.blocksscan.io/

If you have deployed your Smart Contract on Mainnet then visit:

XDC Network — XinFinScan Explorer: https://explorer.xinfin.network/

XDC Network — BlocksScan Explorer: https://xdc.blocksscan.io/

Step 2: Paste the Contract Address on the explorer, you will find the text “Are you the contract creator? Verify And Publish your contract source code today!”

Click on the “Verify And Publish” link.

Image description

Step 3: Enter the Contract Name and the appropriate Compiler Version on the Verify Contract Page.

Recheck all the details and Click on the Submit button.

Image description

Visit the code tab to confirm that your Contract has been Verified successfully.

Image description

Important Links related to XDC Network
XDC Network
XinFin (XDC) Remix
XDCPay
XDC Faucet
XDC Web Wallet
XDC Android Wallet

Explorer links for Testnet:
XDC Network — XinFinScan Explorer
XDC Network — BlocksScan Explorer

Explorer links for Mainnet:
XDC Network — XinFinScan Explorer
XDC Network — BlocksScan Explorer

Discussion (0)