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 want to deploy a smart contract Simple Storage to a local Besu through the web3.py. I followed the tutorial by using the send_raw_transaction function (similar to sendSignedTransaction in web3.js). I can get a transaction receipt but the status is 0, which indicates the deployment is not successful.
Acceptance Criteria
receipt's status should be 1
Steps to Reproduce (Bug)
Run a local Besu network (IBFT2.0) with 4 nodes, exposing httpRPC port 8545.
Connect to a RPC node; prepare deployer address and private key.
Compile the Simple Storage smart contract.
Compose all raw transaction options to a dictionary.
Sign the composed transaction using the private key.
Send the signed transaction using send_raw_transaction function.
Expected behavior: [What you expect to happen]
Smart contract deployed successfully.
Actual behavior: [What actually happens]
Smart contract is not deployed successfully.
Frequency: [What percentage of the time does it occur?]
Always
Versions (Add all that apply)
Software version: [besu --version] 21.10
Java version: [java -version] JDK 11
OS Name & Version: [cat /etc/*release] Ubuntu 20.04.3 LTS
Kernel Version: [uname -a] 5.4.0-88-generic
Docker Version: [docker version] 20.10.8
Any suggestions would be much appreciated! BTW, if anyone knows how to pair Besu node with Ethsigner and can share it with me, that would be great. Now, Besu is not friendly to web3.py given that it doesn't support sendTransaction.
Thank you.
Python Code
import json
from web3 import Web3
from web3.middleware import geth_poa_middleware
w3 = Web3(Web3.HTTPProvider(httpUrls[nodes[0]]))
w3.middleware_onion.inject(geth_poa_middleware, layer=0)
genesisFile = 'genesis.json'
with open(genesisFile, 'r') as f:
data = json.load(f)['alloc']
addrKeys = [addr for addr in data.keys()]
addrs = [Web3.toChecksumAddress(addr) for addr in addrKeys]
print('Connected to Besu: ', w3.isConnected(), 'Node: ', httpUrls[nodes[0]], w3.clientVersion)
with open('../build/contracts/SimpleStorage.json') as file:
compiled = json.load(file)
contractAbi = compiled['abi']
contractBin = compiled['bytecode']
contractInit = "000000000000000000000000000000000000000000000000000000000000002F"
fromAddress = addrs[0]
rawtxOptions = {
'nonce': w3.eth.get_transaction_count(fromAddress),
'from': fromAddress,
'to': None,
'value': '0x00',
'data': contractBin+contractInit,
'gas': 90000,
'gasPrice': 18000000000,
'chainId': 1337
}
priv_key = data[addrKeys[0]]['privateKey']
signed_txn = w3.eth.account.sign_transaction(rawtxOptions, priv_key)
tx_hash = w3.eth.send_raw_transaction(signed_txn.rawTransaction)
receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
receipt
Description
I want to deploy a smart contract Simple Storage to a local Besu through the web3.py. I followed the tutorial by using the send_raw_transaction function (similar to sendSignedTransaction in web3.js). I can get a transaction receipt but the status is 0, which indicates the deployment is not successful.
Acceptance Criteria
Steps to Reproduce (Bug)
Expected behavior: [What you expect to happen]
Smart contract deployed successfully.
Actual behavior: [What actually happens]
Smart contract is not deployed successfully.
Frequency: [What percentage of the time does it occur?]
Always
Versions (Add all that apply)
besu --version
] 21.10java -version
] JDK 11cat /etc/*release
] Ubuntu 20.04.3 LTSuname -a
] 5.4.0-88-genericdocker version
] 20.10.8Any suggestions would be much appreciated! BTW, if anyone knows how to pair Besu node with Ethsigner and can share it with me, that would be great. Now, Besu is not friendly to web3.py given that it doesn't support sendTransaction.
Thank you.
Python Code
Output
The text was updated successfully, but these errors were encountered: