I have a python script that retrieves the NFT asset name, and addresses of a specific policy ID using blockfrost API. Now I need to amend the script to add to the csv whether or not the specific asset is in a smart contract (plutus contract) or not. any ideas?
current script:
import requests,csv
blockfrost_api_key=input('blockfrost api key')
project_policy_id=input('project policy id')
base_api="https://cardano-mainnet.blockfrost.io/api/v0"
headers={'project_id':f'{blockfrost_api_key}'}
allAsset=[]
page=1
while True:
response=requests.get(f'{base_api}/assets/policy/{project_policy_id}?page={page}',headers=headers)
if len(response.json())==0:
break
for asset in response.json():
temp={}
asset_hex_name=asset["asset"][len(project_policy_id):]
temp['name']=bytearray.decode(bytearray.fromhex(asset_hex_name))
temp['asset']=asset['asset']
allAsset.append(temp)
page+=1
data=[]
for asset in allAsset:
response=requests.get(f'{base_api}/assets/{asset["asset"]}/addresses',headers=headers)
address=response.json()[0]['address']
data.append([asset['name'],address])
print(asset['name'])
file=open('snapshot.csv','w')
csvWriter=csv.writer(file,delimiter=',')
csvWriter.writerows(data)
file.close()
I'm a complete noob and followed a tutorial to get this far. Thanks for any help! greatly appreciated