Using Ethereum Remix

Go to https://remix.ethereum.org/

Writing your smart contract

Copy and paste the code below to HelloPosiChain.sol file

//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

contract HelloPosiChain {

    uint256 private count = 0;
    uint256 moneyStored = 0;

    function incrementCounter() public {
        count += 1;
    }
    function decrementCounter() public {
        count -= 1;
    }

    function addMoney() payable public {
        moneyStored += msg.value;
    }

    function getCount() public view returns (uint256) {
        return count;
    }

    function getMoneyStored() public view returns (uint256){
        return moneyStored;
    }

}

Compiling

Note: Choose a compiler version equal or newer the version used in contract. In this example, the contract using version 0.8.0. So in compile section, we using 0.8.0 too.

Deploying

If you want to deploy the contract to a live network like POSI Chain Testnet or Mainnet, configure your metamask by adding the required POSI Chain networks using this guide. After adding Posi Chain networks into metamask, choose environment by using Inject Provider

After that, we will deploy our contract.

Click the button Deploy, after that a popup confirm transaction will be shown. And just Confirm transaction deployment

Waiting a few seconds, the contract will be deployed to PosiChain. When the deployment success, we have a address of HelloPosiChain.sol in image below.

Referral document

This tutorial shows you how to use basic remix-ethereum. If you want more information please go to: https://remix-ide.readthedocs.io/en/latest/

Last updated