Update README.md

This commit is contained in:
Bill Buchanan
2023-03-21 13:12:25 +00:00
committed by GitHub
parent 609e050642
commit 586acf95c6

View File

@@ -96,18 +96,96 @@ Now run the Python file, and compare the results in L.1.2.
* Hash rate:
* Balance for 1GbVUSW5WJmRCpaCJ4hanUny77oDaWW4to:
## Setting up your Ethereum wallet on Ropsten
The Ropsten network allows a user to test an Ethereum application, and using free Ether. Initially setup your MetaMask wallet. A document to outline how you set this up is [here](https://github.com/billbuchanan/appliedcrypto/blob/main/unit08_blockchain/lab/Metamask.pdf). Once you have set it up, answer the following:
## Introduction
This provides an outline of cryptocurrencies and blockchain:
* Lab (PDF): [here](https://asecuritysite.com/public/blockchain_lab.pdf)
## Part A
**Using blockchain.info, find the details of the genesis block:**
Date created:
Reward:
Number of transactions:
Size of block:
Which account received the mining reward for the genesis block (last four digits):
How many USD does the original miner have in the account they used for the first genesis record:
When did the genesis block creator stop trading?
**L1.2 Using blockchain.info, determine the following:**
Total bitcoins in circulation:
Most recent hash block (last four hex digits):
Block reward per block:
Difficulty:
Average time between blocks:
Market capitalisation (USD):
24 hr price (USD):
24hr transactions (USD):
Hash rate:
Last successful miner:
Maximum block size:
Balance for 1GbVUSW5WJmRCpaCJ4hanUny77oDaWW4to:
**L1.3 Download and created the Python file defined on this page:**
https://asecuritysite.com/encryption/bit
Now run the Python file, and compare the results in L.1.2.
Total bitcoins in circulation:
Most recent hash block (last four hex digits):
Block reward per block:
Difficulty:
Average time between blocks:
Market capitalisation (USD):
24 hr price (USD):
24hr transactions (USD):
Hash rate:
## B Ethereum
## Setting up your Ethereum wallet on Sepolia
The Sepolia network allows a user to test an Ethereum application, and using free Ether. Initially setup your MetaMask wallet. A document to outline how you set this up is [here](https://github.com/billbuchanan/appliedcrypto/blob/main/unit08_blockchain/lab/Metamask.pdf). Once you have set it up, answer the following:
* What is your public ID (just define the first four hex values)?
* Find out someone else's public ID, and send them 0.001 Ether. If you are doing the lab on your own, send it to Bill (ID: 0xbB15B38e4ef6aF154b89A2E57E03Cd5cbD752233).
* Can you see the transaction on the Ethereum network? An example of a wallet is [here](https://ropsten.etherscan.io/address/0xbb15b38e4ef6af154b89a2e57e03cd5cbd752233).
* Can you see the transaction on the Ethereum network? An example of a wallet is [here](https://sepolia.etherscan.io/address/0xbb15b38e4ef6af154b89a2e57e03cd5cbd752233).
* Can you see your transaction on the Ethereum network for the person you send it to?
* What was the transaction fee for the transfer? If you were using the main Ethereum network, how much would the transaction cost in Dollars?
* Ask someone to send you 0.001 Ether. Did you receive it? If you are doing the lab on your own, ask your lab tutor to send you 0.001 Ether.
## Creating a Smart Contract in Ethereum
So, lets write a bit of code that does some simple maths. In the following we will implement sqrt(), sqr(), mul(), sub(), and add():
So, lets write a bit of code that does some simple maths. In the following we will implement sqrt(), sqr(), mul(), sub(), and add(). First, we open up https://remix.ethereum.org/. and enter the following Solidy contract:
```solidity
pragma solidity ^0.8.0;
@@ -145,7 +223,7 @@ Once entered, we can then compile it with the Solidity compiler. It is important
![here](https://asecuritysite.com/public/eth002.png)
Once compiled we can then deploy the smart contract to a test network (Ropsten). For this , we need to connect our Metamask wallet:
Once compiled we can then deploy the smart contract to a test network (Sepolia). For this , we need to connect our Metamask wallet:
![here](https://asecuritysite.com/public/eth003.png)
@@ -159,7 +237,13 @@ And clicking through gives us the address of the contract, and then viewing it o
![here](https://asecuritysite.com/public/eth005.png)
The address here is 0x0895.., so we can view the smart contract from: [here](https://ropsten.etherscan.io/address/0x0895a540cff8e7829284f1d9c55daf624d6e2df9). We now need to verify and publish the contact, with click on “Verify and Publish”:
The address in the screenshot above is 0x0895.., so you can click on your own address and view the smart contract in Etherscan.
In another example:
![image](https://user-images.githubusercontent.com/44439128/205040755-0796dba5-c8ab-4f6e-ad74-5e023e32d4fb.png)
The address of the contract is "0x3a40..", so you can visit it from from: [here](https://sepolia.etherscan.io/address/0x3a407068a13bfef0db1e319c364c153391b158cf). We now need to verify and publish the contact, with click on “Verify and Publish”:
![here](https://asecuritysite.com/public/eth006.png)
@@ -177,7 +261,7 @@ We then need to add your code for it to be checked:
![here](https://asecuritysite.com/public/eth009.png)
We now have the contract published to the Ropsten test network:
We now have the contract published to the Sepolia test network:
![here](https://asecuritysite.com/public/eth010.png)
@@ -455,7 +539,7 @@ The wallet ID is the public ID of your wallet in Metamask. Now we compile:
![Alt text](https://asecuritysite.com/public/sc01.png)
Next, we will deploy to the Ropsten test network:
Next, we will deploy to the Sepolia test network:
![Alt text](https://asecuritysite.com/public/sc02.png)
@@ -471,11 +555,13 @@ Once deployed, we can view the contract details:
![Alt text](https://asecuritysite.com/public/sc05.png)
And can then view the transaction for the contact [<a href="https://ropsten.etherscan.io/tx/0x70604b7c25c12eea5210c75afaa89879f383dc94b894d570f06925d0d95b7fdb" target="_blank">here</a>]:
And can then view the transaction for the contract:
<!-- [<a href="https://ropsten.etherscan.io/tx/0x70604b7c25c12eea5210c75afaa89879f383dc94b894d570f06925d0d95b7fdb" target="_blank">here</a>] -->
![Alt text](https://asecuritysite.com/public/sc06.png)
And then view the contact [here](https://ropsten.etherscan.io/address/0x7db2f938e1037a13dde315634a71a91625542a52")]:
And then view the contact:
<!-- [here](https://ropsten.etherscan.io/address/0x7db2f938e1037a13dde315634a71a91625542a52")] -->
![Alt text](https://asecuritysite.com/public/sc07.png)
@@ -515,7 +601,8 @@ We can now transfer the cryptocurrency to another wallet:
![Alt text](https://asecuritysite.com/public/sc16.png)
We can view the ENUToken: [here](https://ropsten.etherscan.io/token/0x7db2f938e1037a13dde315634a71a91625542a52)]:
We can view the ENUToken:
<!-- [here](https://ropsten.etherscan.io/token/0x7db2f938e1037a13dde315634a71a91625542a52)] -->
![Alt text](https://asecuritysite.com/public/sc17.png)
@@ -525,6 +612,8 @@ Now answer the following:
* Now send 0.1 of your token to someone else's wallet. If you want, you can send to your tutor's wallet. Bill's wallet is 0xbb15b38e4ef6af154b89a2e57e03cd5cbd752233
* Did they receive the token?
## Saving the state
Smart contracts give us the opportunity to store data in a stateful way, and where we can add and delete data within the smart contact, and then view a current state. So lets do a simple contact of adding cities to a string array. Overall it will cost us some gas to add and delete strings, but not to view the state. The contract we will use is: