Solidity

This chapter describes the Solidity language and development environment.

Solidity is an advanced object-oriented language for implementing smart contracts, a program that controls the behavior of accounts within Ethereum states. Solidity is a bracket-type language influenced by C++, Python, and JavaScript designed to work with Ethereum Virtual Machines(EVMs). Solidity is statically typed and supports inheritance, library, and complex user-defined types, among other features.

Solidity allows creating contracts for purposes such as voting, crowdfunding, blind auctions, and multi-signed wallets.

Integrated Development Environment(IDE)

Various environments support Solidity. It can be used by installing Solidity Plugin from browser-based Remix to popular IDE tools such as IntelliJ and Visual Studio.

How to use Remix

Go to https://remix.ethereum.org and: Storage.sol, Owner.sol, and Ballot.sol are shown in the contracts directory, and to create a new smart contract, select it to erase it and create a new file.

Create and view the following example smart contracts: The example Smart Contract provides the ability to read count values through the get() function and raise or lower count values through the inc(), and dec() functions.

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.11;

contract Counter {
    uint256 count;
    
    constructor(uint256 _count) {
        count = _count;
    }
    
    function get() public view returns (uint256) {
        return count;
    }
    
    function inc() public {
        count += 1;
    }
    
    function dec() public {
        count -= 1;
    }
}

Once the code is written, compile after selecting the correct compiler version on the Solidity Compiler screen.

From the Deploy & Run Transactions screen, you can select the environment you want to deploy and deploy Smart Contract to test it. The figure below is an example of a deployment to the WEMIX3.0 testnet using the "Injected Provider-Metamask" provided by Remix.

If you are using MetaMask, you must add WEMIX3.0 Testnet as follows: The gas fee of WEMIX3.0 Testnet is different from Ethereum, so you need to change it when you send it. You can change Max fee to 100 GWEI and Max priority fee to 100.000000001 GWEI.

For more information about adding networks and setting gas costs, see Use MetaMask.