hujianglang / blockchain

0 stars 0 forks source link

Python 查询address 余额 #2

Open hujianglang opened 2 years ago

hujianglang commented 2 years ago

安装web3的包: Pip install web3 Pip list 查看已安装的包 链RPC地址: Bsc:https://bsc-dataseed1.binance.org:443 Polygon: https://rpc-mainnet.matic.network/

代码: from web3 import Web3, HTTPProvider address = '0x00' # address rpc = 'https://rpc-mainnet.matic.network' web3 = Web3(HTTPProvider(rpc)) balance = web3.fromWei(web3.eth.getBalance(address), "ether") print(balance)

参考: https://mirror.xyz/0xD42F93B38f6f2Cc9Ee67e95B142345F3C3E1E7B6/UfpZl7CHV2ZK0iCieQZlPU5GqKaKke-Eiqd65fYdVSU