EDIT: In short, I want to use Brownie to deploy smartContracts to HyperLedger-Besu network on my local machine. For some reason, it doesn't work, so I wanted to ask if anyone here had experience with such an issue. I described my specific problem in more detail below.
I tried to deploy a basic Migrate.sol
smartContract on my local instance of HyperLedger-Besu (named besulocal
) by using Brownie.
I added its configuration to the brownie's network-config.yaml
- name: HyperLedger-Besu
chainid: 1337
id: besulocal
host: http://localhost:8545
block_time: 5
Then confirmed it indeed works by checking the balance of pre-funded account acct
. (Screenshoot below)
However, when I am trying to migrate the Migrations.sol to the besulocal
I get this Error:
Transaction sent: 0xc3f86ca503d3d5f26dc57b30ee3039c4ecd4641ee7d0e5c8c223bd9032d38a41
Gas price: 0.0 gwei Gas limit: 191019 Nonce: 33
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.8/dist-packages/eth_brownie-1.18.1-py3.8.egg/brownie/network/contract.py", line 532, in __call__
return tx["from"].deploy(
File "/usr/local/lib/python3.8/dist-packages/eth_brownie-1.18.1-py3.8.egg/brownie/network/account.py", line 510, in deploy
receipt, exc = self._make_transaction(
File "/usr/local/lib/python3.8/dist-packages/eth_brownie-1.18.1-py3.8.egg/brownie/network/account.py", line 759, in _make_transaction
receipt = TransactionReceipt(
File "/usr/local/lib/python3.8/dist-packages/eth_brownie-1.18.1-py3.8.egg/brownie/network/transaction.py", line 221, in __init__
target=self._await_confirmation, args=(tx["blockNumber"], required_confs), daemon=True
File "/usr/local/lib/python3.8/dist-packages/web3-5.27.0-py3.8.egg/web3/datastructures.py", line 51, in __getitem__
return self.__dict__[key] # type: ignore
KeyError: 'blockNumber'
The interesting thing is that when I try to deploy to ganache-cli
everything works as intended, but fails on besulocal
This is my deployment-script:
from brownie import Migrations, accounts
def main():
acct = accounts.load('besulocal_account') #Account Pre-funded with ETH
Migrations.deploy({'from': acct})
Would appreciate if anyone had any idea on how to deal with this.
NOTE: ganache-cli
and besulocal
are using the same port, but they are not active simultaneously. I shut down ganache-cli
before using besulocal
and vice versa.
EDIT2: The first answer mentioned that signer might be an issue. So I tried to transfer some ETH from pre-funded account to another address. And I indeed got the same error; however, after checking the balances, I noticed the transfer did indeed pass through regardless of the error. See screenShoot below:
Best Answer
The problem is due to Besu not fully following the standard JSON-RPC API for
eth_getTransactionByHash
.After signing the tx, brownie checks the status of the tx using
eth_getTransactionByHash
and looks forblockNumber
field. API standard says that filed should benull
if the tx is pending, or equal to the block number if the tx is mined.On the contrary, Besu's response does not contain the
blockNumber
field in case of pending txs, and this causes the error.Example of Besu response for a pending tx:
Example in case of mined transaction:
I opened a dedicated issue on the official Besu repo, and now it's fixed with PR3906. Brownie should be able to work fine with the next Besu's release.