from web3 import Web3, HTTPProvider
true = True
false = False
# 根据实际填写
chainId = 9000
web3 = Web3(HTTPProvider('http://192.168.3.23:8545'))
privateKey = 'e42b...c6b7'
fromAddr =web3.eth.account.from_key(privateKey).address
nonce = web3.eth.getTransactionCount(fromAddr)
gasPrice = web3.eth.gasPrice
print(fromAddr)
rawTx = {
'from': fromAddr,
'nonce': nonce,
'gasPrice': gasPrice,
'gas': 1000000,
'value': web3.toWei(0, 'ether'),
"chainId": chainId,
'data': '0x608060...8070033'
}
def deploy(rawTx):
signedTx = web3.eth.account.signTransaction(rawTx,private_key=privateKey)
hashTx = web3.eth.sendRawTransaction(signedTx.rawTransaction).hex()
receipt = web3.eth.waitForTransactionReceipt(hashTx)
return receipt
if __name__ == '__main__':
receipt = deploy(rawTx)
print('address: ' + receipt['contractAddress'])