Task C

mail@pastecode.io avatar
unknown
python
3 years ago
1.3 kB
2
Indexable
Never
#!/usr/bin/python
# Get (X+Y) holders + Balance ERC20
import requests
balance = 5000
NFT1="0xd21a23606D2746f086f6528Cd6873bAD3307b903"
NFT2="0xB796485fE35C926328914cD4CD9447D095d41F7f"
ERC20="0x5c761c1a21637362374204000e383204d347064c"
LNFT1=[]
LNFT2=[]
LERC20=[]
chainid=1
URL1 = "https://api.covalenthq.com/v1/"+str(chainid)+"/tokens/"+NFT1+"/token_holders/?&key=ckey_80d0aba5413a4a5a8e0d2d315f6";
URL2 = "https://api.covalenthq.com/v1/"+str(chainid)+"/tokens/"+NFT2+"/token_holders/?&key=ckey_80d0aba5413a4a5a8e0d2d315f6";
URL3 = "https://api.covalenthq.com/v1/"+str(chainid)+"/tokens/"+ERC20+"/token_holders/?&key=ckey_80d0aba5413a4a5a8e0d2d315f6";
r1 = requests.get(url = URL1)
r2 = requests.get(url = URL2)
r3 = requests.get(url = URL3)
dataNFT1 = r1.json()
dataNFT2 = r2.json()
dataERC20 = r3.json()
for item in dataNFT1['data']['items']:
    LNFT1.append(item['address'])
for item in dataNFT2['data']['items']:
    LNFT2.append(item['address'])
for item in dataERC20['data']['items']:
    if(int(item['balance'])>balance):
        LERC20.append(item['address'])

# set intersection of NFT1 + NFT2 + has an ERC20 balance > 'balance' (defined above)
XPlusYplusBalance=(list(set(LNFT1) & set(LNFT2) & set(LERC20)))
for address in XPlusYplusBalance:
    print(address)