DEV Community

Ayden
Ayden

Posted on

Analyze stolen NFTs that been marked by opensea

Overview

This is a hackathon data analytics project. I analyze the top 2300 nfts sort by volume。 You can find the detail list from my GitHub repo. Or you can click here。
https://github.com/coffiasd/hackathon-data-analytics/blob/main/data/RankNFTS.csv

CSV Data

Below is all csv file that i collect.RankNFTs.csv is the top 2300 NFTs list. tokenIds/{contract}.csv is stolen NFTs tokenID list.lastSalePrice/{contract}.csv is the last sale price of each tokenId.

  • RankNFTs.csv
  • tokenIds/{contract}.csv
  • lastSalePrice/{contract}.csv

Python script

You can get the all scripts my github repo above.

  • getNFTsRankTopVolume.py(get top volume NFTs && stolen NFTs list)
  • getNFTsDetail.py(get NFT’s last sale price)
  • caculateStolen.py(caculate Result)
def getNftsRankTopVolume(page):
    url = "https://api.traitsniper.com/v1/collections?page=" + \
        str(page)+"&limit=100&sort_total_volume=desc"

    headers = {
        "accept": "application/json",
        "x-ts-api-key": TraitsniperApiKey
    }

    response = requests.get(url, headers=headers)
    resp_dict = json.loads(response.text)

def caculateContractItem(contractAddress, table):
    # get collection detail
    item = getCollectionDetail(contractAddress)

    # read stolen nfts list
    data = pd.read_csv("../data/stolen/lastSalePrice/" +
                       contractAddress+".csv", header=None)
    # caculate items
    num = data.count()
    sum = 0
    for index, row in data.iterrows():
        if row[1] > item["floor_price"]:
            sum += row[1]
        else:
            sum += item["floor_price"]
    table.rows.append([item["nft_name"], contractAddress, item["total_volume"],
                       sum, sum/item["total_volume"], num[0]])
Enter fullscreen mode Exit fullscreen mode

Fetch Collections

First and foremost we need to get the list of each collection and then get the list of stolen nfts.

How to calculate the price of each stolen nft?

  • If this item has a history price && the latest_price>floor_price take the latest_price as worth.
  • If latest_price<floor_price take the floor_price as worth.
  • If this item does’t has a history price then take the current floor price as worth.
# worth
# latest_history_price
# floor_price
var worth = 0

if(item_has("latest_history_price")){
    if(latest_history_price> floor_price){
    worth = latest_history_price
    }else{
    worth = floor_price
    }
}else{
    worth = floor_price
}
Enter fullscreen mode Exit fullscreen mode

Calculate

I analyze each marked as stolen contract to find out the stolen volume and the numbers of stolen NFTs.Below is the output after i run caculateStolen.py you can get source code from my github repo above.

Image description

Top comments (0)