Skip to content

Commit

Permalink
updated: deps, contract deployment log, wait for receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
Salmandabbakuti committed Feb 29, 2024
1 parent 272b60c commit d89cbd8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
# - name: Install Windows Build Tools (if needed)
Expand All @@ -45,9 +45,9 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ A simple IoT and Blockchain based application to demonstrate the use of blockcha

- [Node.js](https://nodejs.org/en/download/)
- [Python](https://www.python.org/downloads/)
- Windows 8+ or MacOS X
- Windows 8+ (for simulating GPIO pins on Windows), Raspberry Pi (for using actual GPIO pins)
- [Windows Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) - Only for Windows (Simulating GPIO pins on Windows)

> Note: _Windows Build Tools is required to install web3. Install through Powershell(Admin) if not installed already_
Expand Down
4 changes: 4 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
contract = w3.eth.contract(abi=abi, bytecode=bytecode)
tx_hash = contract.constructor().transact()
tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
print('Contract deployed at:', tx_receipt.contractAddress)
contract_instance = w3.eth.contract(address=tx_receipt.contractAddress, abi=abi)

# Get initial pin status
Expand All @@ -83,6 +84,9 @@ def set_pin_status(pin_id, action):
tx_hash = contract_instance.functions.setPinStatus(pin_number, pin_status).transact({'from': w3.eth.accounts[0]})
print('Transaction submitted:', tx_hash.hex())

tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
print('Transaction confirmed in block:', tx_receipt.blockNumber)

pin_status = contract_instance.functions.pinStatus(pin_number).call()
print(f'Pin {pin_number} status changed to {pin_status}')

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iot-blockchain-demo",
"version": "1.0.0",
"version": "2.2.0",
"description": "First implementation of enhanced security in IoT using Blockchain",
"main": "",
"scripts": {
Expand All @@ -13,7 +13,7 @@
"license": "ISC",
"dependencies": {},
"devDependencies": {
"hardhat": "2.17.2",
"hardhat": "2.20.1",
"pip": "0.0.1"
}
}
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
flask~=2.3.3
web3==6.9.0
simplejson==3.19.1
flask~=3.0.2
web3==6.15.1
simplejson==3.19.2
GPIOSimulator==0.1 #Rasp-pi Simulator package
#RPi.GPIO==0.7.0 #use when connected to real rasp-pi
2 changes: 1 addition & 1 deletion static/style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
body {
background-image: url("background.jpg");
background: url("background.jpg");
font-family: "Courgette", cursive;
background-attachment: fixed;
color: white;
Expand Down

0 comments on commit d89cbd8

Please sign in to comment.