Skip to content
Open
Show file tree
Hide file tree
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
54 changes: 1 addition & 53 deletions assignments/1-block-observation/README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1 @@
# The Ethereum Blockchain Explorer (Etherscan) & Transaction Hash

## The Ethereum Blockchain Explorer (Etherscan)

### Overview Page Observations
On the Etherscan overview homepage, I observed the following key metrics in the network:
1. **Live Ether Price**: In real-time, this displays the current price of ETH.
2. **Market Capitalization**: Represents the total value of all ETH in circulation.
3. **Transactions**: This displays the total number of transactions processed on the Ethereum network, increasing continuously as new transactions are confirmed.
4. **Last Finalized Block**: This shows us the most recent block that has achieved finality.


#### A table that display the lastest blocks
After clicking on the latest block at the time, there are several details I observed about the block and they are:

1. **Block Height**: This indicates the length of the blockchain, increases after the addition of the new block.
2. **Status**: As at the time I checked it, it was finalized. This shows the status of the finality of the block.
3. **Proposed On** and **Timestamps**: Basically, this gives us information about when the transaction started.
4. Withdrawals
5. **Fee Recipient**: This gives us basic information about the receiver of the transaction.
6. **Block Reward**: This is the total reward earned from the miner.
7. Gas information
8. Block Size
9. **Extra Data**: More information about the recipient


#### A table that display the lastest transactions

After clicking on the latest transaction at the time, there are several transaction details and they are:

##### Transaction Overview
1. **Transaction Hash**: A unique 64-bit character id for ay given transaction.
2. **Status**: This shows us the progress of the transaction.
3. Block
4. Timestamp**: Giving us information about when the transaction took place.

##### Transaction Cost Details
This gives us information about the cost of transaction like its fee and gas price.

Etherscan serves as a powerful blockchain explorer for transparently analyzing Ethereum's blocks, transactions, and validator behavior.

## Transaction Hash

### Overview Page Observations

Similar to the overview page of the etherscan of several transactions and blocks, this page gives us a keen view of the information that pertains to a particular transaction.

We have the transaction hash of this transaction, the status, spacific block and the amount of block confirmations, timestamp from the time it was proposed (I think), the sender and receiver's wallet address, value of eth sent, transaction fee and gas price.

There's also a button that when clicked, will show us a dropdown of more information about the transaction

## Conclusion
In conclusion, I think the Etherscan is a powerful blockchain explorer for analyzing Etherum blocks, transactions, and validator behaviour, transparently.
(Block Explorer)[https://hackmd.io/@GhXpzopCT4GRIXOIrUHk6g/HkXUYNTHZg]
1 change: 1 addition & 0 deletions assignments/1-block-observation/transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(Transaction Concept on Explorer)[https://hackmd.io/@GhXpzopCT4GRIXOIrUHk6g/SJDDJtTHbe]
Binary file added assignments/10-escrow-contract-v2/.DS_Store
Binary file not shown.
57 changes: 57 additions & 0 deletions assignments/10-escrow-contract-v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Sample Hardhat 3 Beta Project (`mocha` and `ethers`)

This project showcases a Hardhat 3 Beta project using `mocha` for tests and the `ethers` library for Ethereum interactions.

To learn more about the Hardhat 3 Beta, please visit the [Getting Started guide](https://hardhat.org/docs/getting-started#getting-started-with-hardhat-3). To share your feedback, join our [Hardhat 3 Beta](https://hardhat.org/hardhat3-beta-telegram-group) Telegram group or [open an issue](https://github.com/NomicFoundation/hardhat/issues/new) in our GitHub issue tracker.

## Project Overview

This example project includes:

- A simple Hardhat configuration file.
- Foundry-compatible Solidity unit tests.
- TypeScript integration tests using `mocha` and ethers.js
- Examples demonstrating how to connect to different types of networks, including locally simulating OP mainnet.

## Usage

### Running Tests

To run all the tests in the project, execute the following command:

```shell
npx hardhat test
```

You can also selectively run the Solidity or `mocha` tests:

```shell
npx hardhat test solidity
npx hardhat test mocha
```

### Make a deployment to Sepolia

This project includes an example Ignition module to deploy the contract. You can deploy this module to a locally simulated chain or to Sepolia.

To run the deployment to a local chain:

```shell
npx hardhat ignition deploy ignition/modules/Counter.ts
```

To run the deployment to Sepolia, you need an account with funds to send the transaction. The provided Hardhat configuration includes a Configuration Variable called `SEPOLIA_PRIVATE_KEY`, which you can use to set the private key of the account you want to use.

You can set the `SEPOLIA_PRIVATE_KEY` variable using the `hardhat-keystore` plugin or by setting it as an environment variable.

To set the `SEPOLIA_PRIVATE_KEY` config variable using `hardhat-keystore`:

```shell
npx hardhat keystore set SEPOLIA_PRIVATE_KEY
```

After setting the variable, you can run the deployment with the Sepolia network:

```shell
npx hardhat ignition deploy --network sepolia ignition/modules/Counter.ts
```
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"_format": "hh3-sol-build-info-1",
"id": "solc-0_8_31-2bb4e90243aac702e22940d03732e66576179f6f",
"solcVersion": "0.8.31",
"solcLongVersion": "0.8.31+commit.fd3a2265",
"userSourceNameMap": {
"contracts/Counter.sol": "project/contracts/Counter.sol"
},
"input": {
"language": "Solidity",
"settings": {
"evmVersion": "osaka",
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"": [
"ast"
],
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata"
]
}
},
"remappings": []
},
"sources": {
"project/contracts/Counter.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.28;\n\ncontract Counter {\n uint public x;\n\n event Increment(uint by);\n\n function inc() public {\n x++;\n emit Increment(1);\n }\n\n function incBy(uint by) public {\n require(by > 0, \"incBy: increment should be positive\");\n x += by;\n emit Increment(by);\n }\n}\n"
}
}
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"_format": "hh3-sol-build-info-1",
"id": "solc-0_8_31-79fb429896f3a0d97ab2b5ff7b4c7d5ebe992caa",
"solcVersion": "0.8.31",
"solcLongVersion": "0.8.31+commit.fd3a2265",
"userSourceNameMap": {
"contracts/Escrow.sol": "project/contracts/Escrow.sol"
},
"input": {
"language": "Solidity",
"settings": {
"evmVersion": "osaka",
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"": [
"ast"
],
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata"
]
}
},
"remappings": []
},
"sources": {
"project/contracts/Escrow.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.31;\n\ncontract Escrow {\n uint public transactionCount = 1;\n address public contractAddress;\n\n enum State {\n AWAITING_PAYMENT,\n AWAITING_DELIVERY,\n AWAITING_FUNDS_DISBURSEMENT,\n COMPLETE\n }\n\n struct Order {\n uint id;\n address buyer;\n address seller;\n uint amount;\n State status;\n }\n\n mapping(uint => Order) public orders;\n\n constructor() {\n contractAddress = msg.sender;\n }\n\n modifier notAddressZero(address _addr) {\n require(_addr != address(0), 'Address cant be address zero');\n _;\n }\n\n modifier onlyBuyer(uint _id) {\n require(\n msg.sender == orders[_id].buyer,\n 'Only buyer can call this function'\n );\n _;\n }\n\n modifier onlySeller(uint _id) {\n require(\n msg.sender == orders[_id].seller,\n 'Only seller can call this function'\n );\n _;\n }\n\n modifier onlyContract() {\n require(\n msg.sender == contractAddress,\n 'Only Contract can call this function'\n );\n _;\n }\n\n modifier validState(uint _id, State _state) {\n require(_state == orders[_id].status, 'Invalid state');\n _;\n }\n\n modifier paymentMade(uint _id) {\n require(\n address(this).balance >= orders[_id].amount && address(this).balance > 0,\n 'Amount not paid'\n );\n _;\n }\n\n function createOrder(address _buyer, address _seller) public {\n require(_buyer != address(0), 'Address cant be address zero');\n require(_seller != address(0), 'Address cant be address zero');\n orders[transactionCount].id = transactionCount;\n orders[transactionCount].buyer = _buyer;\n orders[transactionCount].seller = _seller;\n orders[transactionCount].status = State.AWAITING_PAYMENT;\n transactionCount++;\n }\n\n function deposit(\n uint _id\n ) public payable onlyBuyer(_id) validState(_id, State.AWAITING_PAYMENT) {\n orders[_id].amount = msg.value;\n orders[_id].status = State.AWAITING_DELIVERY;\n }\n\n function sendDelivery(\n uint _transactionCount\n )\n public\n paymentMade(_transactionCount)\n validState(_transactionCount, State.AWAITING_DELIVERY)\n {\n orders[_transactionCount].status = State.AWAITING_FUNDS_DISBURSEMENT;\n }\n\n function releaseFundsToSeller(\n uint _id\n )\n external\n onlyContract\n paymentMade(_id)\n validState(_id, State.AWAITING_FUNDS_DISBURSEMENT)\n {\n Order memory _order = orders[_id];\n\n (bool success, ) = _order.seller.call{value: _order.amount}('');\n require(success, 'Transfer failed');\n _order.status = State.COMPLETE;\n orders[_id] = _order;\n }\n\n function refundFundsToBuyer(\n uint _id\n )\n external\n onlyContract\n paymentMade(_id)\n validState(_id, State.AWAITING_DELIVERY)\n {\n Order storage _order = orders[_id];\n\n (bool success, ) = _order.buyer.call{value: _order.amount}('');\n require(success, 'Refund failed');\n }\n}\n"
}
}
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"_format": "hh3-artifact-1",
"contractName": "Counter",
"sourceName": "contracts/Counter.sol",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "by",
"type": "uint256"
}
],
"name": "Increment",
"type": "event"
},
{
"inputs": [],
"name": "inc",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "by",
"type": "uint256"
}
],
"name": "incBy",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "x",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "0x6080604052348015600e575f5ffd5b506101ff8061001c5f395ff3fe608060405234801561000f575f5ffd5b506004361061003f575f3560e01c80630c55699c14610043578063371303c01461005d57806370119d0614610067575b5f5ffd5b61004b5f5481565b60405190815260200160405180910390f35b61006561007a565b005b61006561007536600461016d565b6100c3565b5f8054908061008883610198565b9091555050604051600181527f51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a819060200160405180910390a1565b5f81116101225760405162461bcd60e51b815260206004820152602360248201527f696e6342793a20696e6372656d656e742073686f756c6420626520706f73697460448201526269766560e81b606482015260840160405180910390fd5b805f5f82825461013291906101b0565b90915550506040518181527f51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a819060200160405180910390a150565b5f6020828403121561017d575f5ffd5b5035919050565b634e487b7160e01b5f52601160045260245ffd5b5f600182016101a9576101a9610184565b5060010190565b808201808211156101c3576101c3610184565b9291505056fea2646970667358221220714be3f432bbb16a1a225de1d2f83cd74f963977f84f86bd9b1e99eff686ee9764736f6c634300081f0033",
"deployedBytecode": "0x608060405234801561000f575f5ffd5b506004361061003f575f3560e01c80630c55699c14610043578063371303c01461005d57806370119d0614610067575b5f5ffd5b61004b5f5481565b60405190815260200160405180910390f35b61006561007a565b005b61006561007536600461016d565b6100c3565b5f8054908061008883610198565b9091555050604051600181527f51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a819060200160405180910390a1565b5f81116101225760405162461bcd60e51b815260206004820152602360248201527f696e6342793a20696e6372656d656e742073686f756c6420626520706f73697460448201526269766560e81b606482015260840160405180910390fd5b805f5f82825461013291906101b0565b90915550506040518181527f51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a819060200160405180910390a150565b5f6020828403121561017d575f5ffd5b5035919050565b634e487b7160e01b5f52601160045260245ffd5b5f600182016101a9576101a9610184565b5060010190565b808201808211156101c3576101c3610184565b9291505056fea2646970667358221220714be3f432bbb16a1a225de1d2f83cd74f963977f84f86bd9b1e99eff686ee9764736f6c634300081f0033",
"linkReferences": {},
"deployedLinkReferences": {},
"immutableReferences": {},
"inputSourceName": "project/contracts/Counter.sol",
"buildInfoId": "solc-0_8_31-2bb4e90243aac702e22940d03732e66576179f6f"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// This file was autogenerated by Hardhat, do not edit it.
// prettier-ignore
// tslint:disable
// eslint-disable
// biome-ignore format: see above

export interface Counter$Type {
readonly _format: "hh3-artifact-1";
readonly contractName: "Counter";
readonly sourceName: "contracts/Counter.sol";
readonly abi: [{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"by","type":"uint256"}],"name":"Increment","type":"event"},{"inputs":[],"name":"inc","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"by","type":"uint256"}],"name":"incBy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"x","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}];
readonly bytecode: "0x6080604052348015600e575f5ffd5b506101ff8061001c5f395ff3fe608060405234801561000f575f5ffd5b506004361061003f575f3560e01c80630c55699c14610043578063371303c01461005d57806370119d0614610067575b5f5ffd5b61004b5f5481565b60405190815260200160405180910390f35b61006561007a565b005b61006561007536600461016d565b6100c3565b5f8054908061008883610198565b9091555050604051600181527f51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a819060200160405180910390a1565b5f81116101225760405162461bcd60e51b815260206004820152602360248201527f696e6342793a20696e6372656d656e742073686f756c6420626520706f73697460448201526269766560e81b606482015260840160405180910390fd5b805f5f82825461013291906101b0565b90915550506040518181527f51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a819060200160405180910390a150565b5f6020828403121561017d575f5ffd5b5035919050565b634e487b7160e01b5f52601160045260245ffd5b5f600182016101a9576101a9610184565b5060010190565b808201808211156101c3576101c3610184565b9291505056fea2646970667358221220714be3f432bbb16a1a225de1d2f83cd74f963977f84f86bd9b1e99eff686ee9764736f6c634300081f0033";
readonly deployedBytecode: "0x608060405234801561000f575f5ffd5b506004361061003f575f3560e01c80630c55699c14610043578063371303c01461005d57806370119d0614610067575b5f5ffd5b61004b5f5481565b60405190815260200160405180910390f35b61006561007a565b005b61006561007536600461016d565b6100c3565b5f8054908061008883610198565b9091555050604051600181527f51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a819060200160405180910390a1565b5f81116101225760405162461bcd60e51b815260206004820152602360248201527f696e6342793a20696e6372656d656e742073686f756c6420626520706f73697460448201526269766560e81b606482015260840160405180910390fd5b805f5f82825461013291906101b0565b90915550506040518181527f51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a819060200160405180910390a150565b5f6020828403121561017d575f5ffd5b5035919050565b634e487b7160e01b5f52601160045260245ffd5b5f600182016101a9576101a9610184565b5060010190565b808201808211156101c3576101c3610184565b9291505056fea2646970667358221220714be3f432bbb16a1a225de1d2f83cd74f963977f84f86bd9b1e99eff686ee9764736f6c634300081f0033";
readonly linkReferences: {};
readonly deployedLinkReferences: {};
readonly immutableReferences: {};
readonly inputSourceName: "project/contracts/Counter.sol";
readonly buildInfoId: "solc-0_8_31-2bb4e90243aac702e22940d03732e66576179f6f";
};

import "hardhat/types/artifacts";
declare module "hardhat/types/artifacts" {
interface ArtifactMap {
["Counter"]: Counter$Type;
["contracts/Counter.sol:Counter"]: Counter$Type;
}
}
Loading