In the deployment of intelligent contracts, I use the web3 call web3. Eth. Chain_id method, the error "web3. Exceptions. MethodUnavailable: {' code ': - 32601,' the message: 'The method eth_chainId does not exist/is not available'}”
The error:
Traceback (most recent call last):
File "F:\pycharm\WorkTest\TrailChain-main\POC\exp1.py", line 83, in <module>
notaryAddress, notaryABI, trackerAddress, trackerABI= setup.deploySystemcontracts(trailchainURL)
File "F:\pycharm\WorkTest\TrailChain-main\POC\setup.py", line 64, in deploySystemcontracts
'chainId': web3.eth.chain_id,
File "F:\python\lib\site-packages\web3\eth\eth.py", line 145, in chain_id
return self._chain_id()
File "F:\python\lib\site-packages\web3\module.py", line 75, in caller
result = w3.manager.request_blocking(
File "F:\python\lib\site-packages\web3\manager.py", line 321, in request_blocking
return self.formatted_response(
File "F:\python\lib\site-packages\web3\manager.py", line 274, in formatted_response
raise MethodUnavailable(error)
web3.exceptions.MethodUnavailable: {'code': -32601, 'message': 'The method eth_chainId does not exist/is not available'}
The code:
web3 = Web3(Web3.HTTPProvider(_trailchainURL))
web3.is_connected()
#
# -- Deploy TrackerSc Contract --
#
tracker = web3.eth.contract(abi=abiTracker, bytecode=bytecodeTracker)
construct_txn = tracker.constructor().build_transaction(
{
'from': account_from['address'],
'nonce': web3.eth.get_transaction_count(account_from['address']),
'chainId': web3.eth.chain_id,
}
)
tx_create = web3.eth.account.signTransaction(construct_txn, account_from['private_key'])
tx_hash = web3.eth.sendRawTransaction(tx_create.rawTransaction)
tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash)