<p>You are also there, all you need to do is to fetch the address using the <code>/addresses</code> endpoint and check if the address has a script flag.</p>

CC BY-SA 4.0
2023-02-15T18:00:26.540Z
@mmahut how do i do this exactly in my current script? I'm so new to scripting. thanks for any help
dpd
CC BY-SA 4.0
2023-02-18T23:56:41.120Z
i figured it out with some help from a buddy. thanks
dpd
CC BY-SA 4.0
2023-02-13T17:53:19.320Z
2023-02-13T17:53:19.320Z
Marek Mahut - StakeNuts
<p>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?</p>
<p>current script:</p>
<pre><code>import requests,csv

blockfrost_api_key=input('blockfrost api key')
project_policy_id=input('project policy id')

base_api=&quot;https://cardano-mainnet.blockfrost.io/api/v0&quot;

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[&quot;asset&quot;][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[&quot;asset&quot;]}/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()
</code></pre>
<p>I'm a complete noob and followed a tutorial to get this far. Thanks for any help! greatly appreciated</p>

<plutus><smart-contract><nft><blockfrost><python>
Need to Retrieve Info from (NFT)Assets in Policy ID to see if they are in a Plutus Contract (smart contract) or Not using Blockfrost API
# Need to Retrieve Info from (NFT)Assets in Policy ID to see if they are in a Plutus Contract (smart contract) or Not using Blockfrost API

(Asked by: username_0 on 2023-02-13)

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

**Tags:** plutus, smart-contract, nft, blockfrost, python

---

## 1 answers

### Answer by username_1 on 2023-02-13. Score: 0 | Accepted answer

You are also there, all you need to do is to fetch the address using the `/addresses` endpoint and check if the address has a script flag.

> **Comments:**
> **username_0**: @mmahut how do i do this exactly in my current script? I'm so new to scripting. thanks for any help  
> **username_0**: i figured it out with some help from a buddy. thanks  

---

