MENU

Nhà Việt

Phục Vụ

24/24

Email Nhà Việt

[email protected]

ERC-20 Token Standard | https://suanha.org

1

from

web3importWeb3

2

3

4

w3=Web3(Web3.HTTPProvider(" https://cloudflare-eth.com "))

5

6

dai_token_addr=" 0x6 B175474E89094C44Da98b954EedeAC495271d0F "

7

weth_token_addr=" 0 xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 "

8

9

acc_address=" 0 xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11 "

10

11

12

13

simplified_abi=[

14

{

15

' inputs ':[{' internalType ':' address ',' name ':' account ',' type ':' address '}],

16

' name ':' balanceOf ',

17

' outputs ':[{' internalType ':' uint256 ',' name ':' ',' type ':' uint256 '}],

18

' stateMutability ':' view ',' type ':' function ',' constant ':True

19

},

20

{

21

' inputs ':[],

22

' name ':' decimals ',

23

' outputs ':[{' internalType ':' uint8 ',' name ':' ',' type ':' uint8 '}],

24

' stateMutability ':' view ',' type ':' function ',' constant ':True

25

},

26

{

27

' inputs ':[],

28

' name ':' symbol ',

29

' outputs ':[{' internalType ':' string ',' name ':' ',' type ':' string '}],

30

' stateMutability ':' view ',' type ':' function ',' constant ':True

31

},

32

{

33

' inputs ':[],

34

' name ':' totalSupply ',

35

' outputs ':[{' internalType ':' uint256 ',' name ':' ',' type ':' uint256 '}],

36

' stateMutability ':' view ',' type ':' function ',' constant ':True

37

}

38

]

39

40

dai_contract=w3.eth.contract(address=w3.toChecksumAddress(dai_token_addr),abi=simplified_abi)

41

symbol=dai_contract.functions.symbol().call()

42

decimals=dai_contract.functions.decimals().call()

43

totalSupply=dai_contract.functions.totalSupply().call()/10* *decimals

44

addr_balance=dai_contract.functions.balanceOf(acc_address).call()/10* *decimals

45

46

47

print(" = = = = = % s = = = = = "%symbol)

48

print(" Total Supply : ",totalSupply)

49

print(" Addr Balance : ",addr_balance)

50

51

weth_contract=w3.eth.contract(address=w3.toChecksumAddress(weth_token_addr),abi=simplified_abi)

52

symbol=weth_contract.functions.symbol().call()

53

decimals=weth_contract.functions.decimals().call()

54

totalSupply=weth_contract.functions.totalSupply().call()/10* *decimals

55

addr_balance=weth_contract.functions.balanceOf(acc_address).call()/10* *decimals

56

57

58

print(" = = = = = % s = = = = = "%symbol)

59

print(" Total Supply : ",totalSupply)

60

print(" Addr Balance : ",addr_balance)

61

Show all

📋Copy

Source: https://suanha.org
Category : Thị Trường

Alternate Text Gọi ngay
Liên kết hữu ích: XSMB