Arsstep
3 min readApr 30, 2021

Today i’d like to share my first short expirience of coding smart contracts on Solidity. Thanks to ParaState project, it gives an opportumity to start thjs activity.

  1. First of all you should to set up your ERC20 wallet to the ParaState Network.

Add a test network to your wallet. Detailed guid here.

Network Name: ParaState
New RPC URL: https://rpc.parastate.io:8545
Chain ID: 123
Currency Symbol (Optional): STATE

2. Second you should to get testnet token from faucet from this link.

3. The deployment of the contract begins with the import of the wallet privet key to the WEB ID.

4. Code part.

It started here:

First of all you should write up lines of code.

I decided to choose digitilizing old-fashined process of bying books (paper books) that lay on store-window.

Let’s imagine it:

Then you should import your wallet number here:

The code is:

pragma solidity ^0.4.26;
contract MyBookStore {

//Decalre state variables of the contract
address public owner;
mapping (address => uint) public BookBalances;

//When ‘MyBookStor’ contract is deployed
// 1. Set the deploying address as the owner of the contract
// 2. Set the deployed smart contract’s book balance to 100
constructor() public {
owner = msg.sender;
BookBalances[address(this)] = 100;
}

//Allow the owner to increase smart contract’s Book balance

function refill(uint amount) public {
require(msg.sender == owner, “Only thew owner can refill”);
BookBalances[address(this)] += amount;
}

//Allow anyone to purchase the books

function purchase (uint amount) public payable {
require(msg.value >= amount*1 ether, “You must pay at least 1 ETH per each book”);
require(BookBalances [address(this)] >= amount, “Not enough books in stock to complete this purchase”);
BookBalances[address(this)] -= amount;
BookBalances[msg.sender] += amount;
}
}

5. Next step is compiling the code. You must be sure that error log is empty:

6. Then we deploy it:

You can find “success” status over tje log field. It marks success of the process.

It was easy enough. Everybody can make his/her own Smart Contract.

Useful links:

Websitehttps://www.parastate.io

Twitterhttps://twitter.com/parastate

Githubhttps://github.com/ParaState/

Telegramhttps://t.me/parastateofficial

Discordhttps://discord.gg/DgKNeJFBXA

Mediumhttps://medium.com/ethereum-on-steroids

No responses yet