I am trying to deploy this code to get the latest transaction and I get this error:
Traceback (most recent call last):
File "/home/elly/practice/web3/deploy.py", line 72, in
nonce = w3.eth.getTransactionCount(my_address)
AttributeError: 'Eth' object has no attribute 'getTransactionCount'
Thank you!
Bellow I add the code:
import json
from web3 import Web3
from solcx import compile_standard, install_solc
import os
from web3.middleware import geth_poa_middleware
with open("./SimpleStorage.sol", "r") as file:
simple_storage_file = file.read()
install_solc("0.6.0")
# Solidity source code
compiled_sol = compile_standard(
{
"language": "Solidity",
"sources": {"SimpleStorage.sol": {"content": simple_storage_file}},
"settings": {
"outputSelection": {
"*": {
"*": ["abi", "metadata", "evm.bytecode", "evm.bytecode.sourceMap"]
}
}
},
},
solc_version="0.6.0",
)
with open("compiled_code.json", "w") as file:
json.dump(compiled_sol, file)
# get bytecode
bytecode = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["evm"][
"bytecode"
]["object"]
# get abi
abi = json.loads(
compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["metadata"]
)["output"]["abi"]
w3 = Web3(Web3.HTTPProvider("http://0.0.0.0:8545"))
chain_id = 1337
if chain_id == 4:
w3.middleware_onion.inject(geth_poa_middleware, layer=0)
print(w3.clientVersion)
my_address="0x6a85d8EB15819bA2C4aeCd242eF8BDAf545ffb75"
private_key="0x1577d778562d1fa5b89ff9581245ea20f7c9edc3fa85771f254a7628bbb0f856"
# Create the contract in Python
SimpleStorage = w3.eth.contract(abi=abi, bytecode=bytecode)
# Get the latest transaction
nonce = w3.eth.getTransactionCount(my_address)
print(nonce)
I am trying to deploy this code to get the latest transaction and I get this error: Traceback (most recent call last): File "/home/elly/practice/web3/deploy.py", line 72, in
nonce = w3.eth.getTransactionCount(my_address)
AttributeError: 'Eth' object has no attribute 'getTransactionCount'
Thank you!
Bellow I add the code: