-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo.py
69 lines (66 loc) · 1.96 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from kw3 import KWeb3
from web3_multicall import Multicall
w3 = KWeb3('https://bsc-dataseed.binance.org/')
busd = w3.busd()
multicall = Multicall(w3.eth) # address is not needed, unless you are on an unsupported chain (check 'web3_multicall/models/enums/network.py')
multicall_result = multicall.aggregate([
busd.name_method(),
busd.symbol_method(),
busd.decimals_method(),
busd.total_supply_method(),
# busd.balance_of_method('YOUR_ADDRESS')
])
multicall_result.jsonprint()
# Prints
#
# {
# "block_number": 7714239,
# "results": [
# {
# "contract_address": "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",
# "function_name": "name",
# "inputs": [],
# "results": [
# "BUSD Token"
# ]
# },
# {
# "contract_address": "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",
# "function_name": "symbol",
# "inputs": [],
# "results": [
# "BUSD"
# ]
# },
# {
# "contract_address": "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",
# "function_name": "decimals",
# "inputs": [],
# "results": [
# 18
# ]
# },
# {
# "contract_address": "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",
# "function_name": "totalSupply",
# "inputs": [],
# "results": [
# 4200999999996203280118545633
# ]
# },
# {
# "contract_address": "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",
# "function_name": "balanceOf",
# "inputs": [
# {
# "name": "account",
# "value": "YOUR_ADDRESS",
# "solidity_type": "address"
# }
# ],
# "results": [
# 0
# ]
# }
# ]
# }