Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified README.md #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 40 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Hello Crypto


The "Hello World" of blockchain and cryptogames! (ノ ˘_˘)ノ 。゜。゚
The "Hello World" of blockchain and cryptogames! (ノ ˘_˘)ノ  。゜。゚

Live demo here: <https://polats.github.io/hello-crypto>

Expand All @@ -14,16 +13,18 @@ npm install -g lite-server
lite-server

```

## Creating It From Scratch

If we want to learn how the pieces come together, it helps to go through the process of creating the Hello Crypto app ourselves.

We can break it down into 3 parts:

* (1) interacting with the Ethereum blockchain in your app,
* (2) creating our own ERC20 token, and
* (3) deploying it on the blockchain.
- (1) interacting with the Ethereum blockchain in your app,
- (2) creating our own ERC20 token, and
- (3) deploying it on the blockchain.

----
---

### Interacting with the Ethereum Blockchain in Your App

Expand Down Expand Up @@ -68,7 +69,7 @@ The app uses our wallet account in Metamask and the web3.js library to interact

**Note:** The SIM Balance error is expected, it appears since we don't have that custom token's smart contract deployed on the blockchain. We will fix that in the next section.

----
---

### Creating Our Own ERC20 Token

Expand All @@ -81,6 +82,7 @@ Creating a custom ERC20 Token is usually the first use case for those learning h
```
npm install -g truffle
```

And then initialize our project by typing:

```
Expand All @@ -99,15 +101,41 @@ npm install @openzeppelin/contracts

You should see a node_modules/@openzeppelin folder once the command completes.

#### 3. Open StandardToken.sol
#### 3. Create StandardToken.sol

Copy the `StandardToken.sol` file from the contracts folder into contracts folder in our project directory.

This is almost a copy of `@openzeppelin/contracts/token/ERC20/ERC20.sol` which implements the IERC20.sol contract interface but instead of having private member variables we will leave them as public.

#### 4. Open SimpleToken.sol
#### 4. Create SimpleToken.sol

Create `SimpleToken.sol` in the contracts folder.

This is our own ERC-20 custom token which inherits from StandardToken.

![Alt text](ss/2.png?raw=true "Change Import")
Copy the following code into `SimpleToken.sol`:

```solidity
pragma solidity >=0.7.0 <0.9.0;

import './StandardToken.sol';

contract SimpleToken is StandardToken {
using SafeMath for uint256;

string public constant name = "SimpleToken";
string public constant symbol = "SIM";
uint8 public constant decimals = 18;

uint256 public constant INITIAL_SUPPLY = 1000 * (10 ** uint256(decimals));

constructor() public {
_totalSupply = INITIAL_SUPPLY;
_balances[msg.sender] = INITIAL_SUPPLY;
transfer(msg.sender, INITIAL_SUPPLY);
}
}
```

#### 4. Add Deployment Script

Expand All @@ -130,6 +158,7 @@ We now setup a local test blockchain by using Truffle, which can be done simply
```
truffle develop
```

![Alt text](ss/4.png?raw=true "Truffle Develop")

Once successful we should see the same screen, with us entering the truffle develop console.
Expand Down Expand Up @@ -162,7 +191,6 @@ You should see the error we had previously is now gone, as our web app is now su

## IN PROGRESS


(optional) interact with contract on truffle console

Send ETH
Expand All @@ -177,7 +205,6 @@ web3.eth.getBalance 0 and 1

web3.eth.sendTransaction({from:Account1, to:Account2, value: 10000})


Send SIM

contractInstance = SimpleToken.deployed().then(i => contractInstance = i)
Expand All @@ -194,7 +221,6 @@ contractInstance.transfer(recipientAddress, 5000)

check new balance


(optional) Setup web3 javascript console

Perform previous ETH transfer operations
Expand All @@ -209,7 +235,6 @@ return balance

Add make-it-rain.html


III. Deploy on the Blockchain

To interact with the blockchain, we’ll need to have our own wallet account. We’ve been using Truffle develop accounts, but now we should use our own by creating one
Expand All @@ -225,4 +250,4 @@ Change make-it-rain settings to call ropsten on testnet instead

Change settings to use ETH instead

Show deployed website
Show deployed website