Python使用web3.py操作以太坊Geth
1、启动geth
geth --datadir data --networkid 130776 --rpc --rpcapi="db,eth,net,web3,personal,miner" --rpcaddr=127.0.0.1 --allow-insecure-unlock
1、建立连接
from web3 import Web3
GETHW3 = Web3(Web3.HTTPProvider('http://xx.xx.xx.xx:8545'))
2、eth基本操作
GETHW3.eth.block_number
3、miner基本操作
GETHW3.geth.miner.start(1)
4、personal基本操作
unlock_result = GETHW3.geth.personal.unlock_account( 帐户地址 , 密码 )
transaction = {
'to': '0x3d08415428cF86c62041d4836dD59e09Eb27E11d',
'value': 10,
'gas': 2000000,
'gasPrice': 10,
'nonce': int(time.time()),
'chainId': 666,
'data': data
}