You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to deploy smartcontract on python. Everything goes nice except when I call the getter function of smart contract, it throws an error. It replaced the main.py in py-eth already and it solved all initial errors.
import json
from web3 import Web3, HTTPProvider
from solc import compile_standard
w3 = Web3(Web3.HTTPProvider("http://localhost:8545"))
print(w3.eth.blockNumber)
greeter.functions.greet().call() //////when I execute this command it throws an error below.
AttributeError: 'ConstantinopleState' object has no attribute 'execute_transaction'
///////output
File "/usr/local/lib/python3.6/dist-packages/web3/contract.py", line 842, in call
**self.kwargs
File "/usr/local/lib/python3.6/dist-packages/web3/contract.py", line 1346, in call_contract_function
return_data = web3.eth.call(call_transaction, block_identifier=block_id)
File "/usr/local/lib/python3.6/dist-packages/eth_utils/functional.py", line 45, in inner
return callback(fn(*args, **kwargs))
File "/usr/local/lib/python3.6/dist-packages/web3/eth.py", line 347, in call
[transaction, block_identifier],
File "/usr/local/lib/python3.6/dist-packages/web3/manager.py", line 94, in request_blocking
response = self._make_request(method, params)
File "/usr/local/lib/python3.6/dist-packages/web3/manager.py", line 81, in _make_request
return request_func(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 50, in apply_formatters
response = make_request(method, params)
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/gas_price_strategy.py", line 18, in middleware
return make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/attrdict.py", line 18, in middleware
response = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/normalize_errors.py", line 9, in middleware
result = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/providers/eth_tester/middleware.py", line 300, in middleware
return make_request(method, [filled_transaction] + params[1:])
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/providers/eth_tester/main.py", line 68, in make_request
response = delegator(self.ethereum_tester, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/providers/eth_tester/defaults.py", line 36, in call_eth_tester
return getattr(eth_tester, fn_name)(*fn_args, **fn_kwargs)
File "/usr/local/lib/python3.6/dist-packages/eth_tester/main.py", line 426, in call
raw_result = self.backend.call(raw_transaction, raw_block_number)
File "/usr/local/lib/python3.6/dist-packages/eth_tester/backends/pyevm/main.py", line 495, in call
block_number,
File "/usr/local/lib/python3.6/dist-packages/eth_tester/backends/pyevm/main.py", line 236, in _execute_and_revert_transaction
computation = state.execute_transaction(transaction)
AttributeError: 'ConstantinopleState' object has no attribute 'execute_transaction'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/init.py", line 5, in
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in
import apt
File "/usr/lib/python3/dist-packages/apt/init.py", line 23, in
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/dist-packages/web3/contract.py", line 842, in call
**self.kwargs
File "/usr/local/lib/python3.6/dist-packages/web3/contract.py", line 1346, in call_contract_function
return_data = web3.eth.call(call_transaction, block_identifier=block_id)
File "/usr/local/lib/python3.6/dist-packages/eth_utils/functional.py", line 45, in inner
return callback(fn(*args, **kwargs))
File "/usr/local/lib/python3.6/dist-packages/web3/eth.py", line 347, in call
[transaction, block_identifier],
File "/usr/local/lib/python3.6/dist-packages/web3/manager.py", line 94, in request_blocking
response = self._make_request(method, params)
File "/usr/local/lib/python3.6/dist-packages/web3/manager.py", line 81, in _make_request
return request_func(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 50, in apply_formatters
response = make_request(method, params)
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/gas_price_strategy.py", line 18, in middleware
return make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/attrdict.py", line 18, in middleware
response = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/normalize_errors.py", line 9, in middleware
result = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/providers/eth_tester/middleware.py", line 300, in middleware
return make_request(method, [filled_transaction] + params[1:])
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/providers/eth_tester/main.py", line 68, in make_request
response = delegator(self.ethereum_tester, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/providers/eth_tester/defaults.py", line 36, in call_eth_tester
return getattr(eth_tester, fn_name)(*fn_args, **fn_kwargs)
File "/usr/local/lib/python3.6/dist-packages/eth_tester/main.py", line 426, in call
raw_result = self.backend.call(raw_transaction, raw_block_number)
File "/usr/local/lib/python3.6/dist-packages/eth_tester/backends/pyevm/main.py", line 495, in call
block_number,
File "/usr/local/lib/python3.6/dist-packages/eth_tester/backends/pyevm/main.py", line 236, in _execute_and_revert_transaction
computation = state.execute_transaction(transaction)
AttributeError: 'ConstantinopleState' object has no attribute 'execute_transaction'
The text was updated successfully, but these errors were encountered:
@MunimShabir I'm not able to reproduce the error you're seeing. I do notice some syntax errors, however. You declare the w3 variable twice (which shouldn't matter in this context, just an observation), and I don't think that evm_version is a valid key in the compile_standard JSON. Feel free to update the code snippet and I can help with troubleshooting if you still need it.
I found the thing that caused this issue. The execute_transaction is removed in a commit in py-evm project: ethereum/py-evm@1992368#diff-2d5d99f4dd8df9b29c7486b27678f9fb
The replacement is apply_transaction method. Fixing this issue is easy. Creating test is a little bit confusing.
By the way, the issue is in eth_tester project, not web3.py project. So I think this issue can be closed.
pip freeze
outputI am trying to deploy smartcontract on python. Everything goes nice except when I call the getter function of smart contract, it throws an error. It replaced the main.py in py-eth already and it solved all initial errors.
import json
from web3 import Web3, HTTPProvider
from solc import compile_standard
w3 = Web3(Web3.HTTPProvider("http://localhost:8545"))
print(w3.eth.blockNumber)
compiled_sol = compile_standard({
"language": "Solidity",
}, "evm_version"='homestead')
w3 = Web3(Web3.EthereumTesterProvider())
bytecode = compiled_sol['contracts']['Greeter.sol']['Greeter']['evm']['bytecode']['object']
abi = json.loads(compiled_sol['contracts']['Greeter.sol']['Greeter']['metadata'])['output']['abi']
Greeter = w3.eth.contract(abi=abi, bytecode=bytecode)
tx_hash = Greeter.constructor().transact()
tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)
greeter = w3.eth.contract(
address=tx_receipt.contractAddress,
abi=abi
)
greeter.functions.greet().call() //////when I execute this command it throws an error below.
AttributeError: 'ConstantinopleState' object has no attribute 'execute_transaction'
///////output
File "/usr/local/lib/python3.6/dist-packages/web3/contract.py", line 842, in call
**self.kwargs
File "/usr/local/lib/python3.6/dist-packages/web3/contract.py", line 1346, in call_contract_function
return_data = web3.eth.call(call_transaction, block_identifier=block_id)
File "/usr/local/lib/python3.6/dist-packages/eth_utils/functional.py", line 45, in inner
return callback(fn(*args, **kwargs))
File "/usr/local/lib/python3.6/dist-packages/web3/eth.py", line 347, in call
[transaction, block_identifier],
File "/usr/local/lib/python3.6/dist-packages/web3/manager.py", line 94, in request_blocking
response = self._make_request(method, params)
File "/usr/local/lib/python3.6/dist-packages/web3/manager.py", line 81, in _make_request
return request_func(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 50, in apply_formatters
response = make_request(method, params)
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/gas_price_strategy.py", line 18, in middleware
return make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/attrdict.py", line 18, in middleware
response = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/normalize_errors.py", line 9, in middleware
result = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/providers/eth_tester/middleware.py", line 300, in middleware
return make_request(method, [filled_transaction] + params[1:])
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/providers/eth_tester/main.py", line 68, in make_request
response = delegator(self.ethereum_tester, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/providers/eth_tester/defaults.py", line 36, in call_eth_tester
return getattr(eth_tester, fn_name)(*fn_args, **fn_kwargs)
File "/usr/local/lib/python3.6/dist-packages/eth_tester/main.py", line 426, in call
raw_result = self.backend.call(raw_transaction, raw_block_number)
File "/usr/local/lib/python3.6/dist-packages/eth_tester/backends/pyevm/main.py", line 495, in call
block_number,
File "/usr/local/lib/python3.6/dist-packages/eth_tester/backends/pyevm/main.py", line 236, in _execute_and_revert_transaction
computation = state.execute_transaction(transaction)
AttributeError: 'ConstantinopleState' object has no attribute 'execute_transaction'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/init.py", line 5, in
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in
import apt
File "/usr/lib/python3/dist-packages/apt/init.py", line 23, in
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/dist-packages/web3/contract.py", line 842, in call
**self.kwargs
File "/usr/local/lib/python3.6/dist-packages/web3/contract.py", line 1346, in call_contract_function
return_data = web3.eth.call(call_transaction, block_identifier=block_id)
File "/usr/local/lib/python3.6/dist-packages/eth_utils/functional.py", line 45, in inner
return callback(fn(*args, **kwargs))
File "/usr/local/lib/python3.6/dist-packages/web3/eth.py", line 347, in call
[transaction, block_identifier],
File "/usr/local/lib/python3.6/dist-packages/web3/manager.py", line 94, in request_blocking
response = self._make_request(method, params)
File "/usr/local/lib/python3.6/dist-packages/web3/manager.py", line 81, in _make_request
return request_func(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 50, in apply_formatters
response = make_request(method, params)
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/gas_price_strategy.py", line 18, in middleware
return make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/attrdict.py", line 18, in middleware
response = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/normalize_errors.py", line 9, in middleware
result = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/providers/eth_tester/middleware.py", line 300, in middleware
return make_request(method, [filled_transaction] + params[1:])
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 48, in apply_formatters
response = make_request(method, formatted_params)
File "/usr/local/lib/python3.6/dist-packages/web3/providers/eth_tester/main.py", line 68, in make_request
response = delegator(self.ethereum_tester, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.6/dist-packages/web3/providers/eth_tester/defaults.py", line 36, in call_eth_tester
return getattr(eth_tester, fn_name)(*fn_args, **fn_kwargs)
File "/usr/local/lib/python3.6/dist-packages/eth_tester/main.py", line 426, in call
raw_result = self.backend.call(raw_transaction, raw_block_number)
File "/usr/local/lib/python3.6/dist-packages/eth_tester/backends/pyevm/main.py", line 495, in call
block_number,
File "/usr/local/lib/python3.6/dist-packages/eth_tester/backends/pyevm/main.py", line 236, in _execute_and_revert_transaction
computation = state.execute_transaction(transaction)
AttributeError: 'ConstantinopleState' object has no attribute 'execute_transaction'
The text was updated successfully, but these errors were encountered: