赞
踩
# web3对象与已部署的用户合约进行通信
rpc = "HTTP合约通讯地址(http url)"
web3 = Web3(HTTPProvider(rpc))
# 当前区块高度
blockNumber = web3.eth.blockNumber
print(blockNumber)
# 获取最新的区块
block = web3.eth.getBlock('latest')
print(block)
# 输出默认区块
print(web3.eth.defaultBlock)
# 将第一个测试账户设置为默认账户
web3.eth.defaultAccount = web3.eth.accounts[0:1]
# 输出默认账户
print(web3.eth.defaultAccount)
# 获取账号信息
accounts = web3.eth.accounts
print("账户列表:", accounts)
# 获取当前gas的价格
print(web3.eth.gasPrice)
address1 = "你的钱包地址"
# 获取eth余额
balance1 = web3.fromWei(web3.eth.getBalance(address1), "ether")
print(balance1)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。