Add support for Polkadot blockchain

Hi, would appreciate the ability to auto-sync to accounts on Polkadot chains. The most urgent for me is Polkadot, of course nice if Kusama and others follow.

Dear Support,

+1

I just recently moved my Polkadot from an Exchange directly to a wallet for staking reasons, would be nice if I could sync my balance as well, similar to the above request.

Kind Regards

Looks like https://polkadot.subscan.io would be the easiest way to implement this. @koinly, I might write a script for myself to get the CSV from data into your custom format, so that I can import it to a custom wallet. If you give me some hints about how you folks do your API syncs, I could try to come up with something to contribute to give your devs a leg-up. (If community contributions are something you’re interested in).

This is already in development and will be released in the coming weeks.

3 Likes

Great to hear, cheers!

In the meantime, here is how I have got my Polkadot transfers and staking rewards into Koinly.

Download the csv files from subscan, and clean them up as follows:

import pandas as pd
import requests
import fnmatch
import os
from datetime import datetime

def get_timestamp(block):
    url = "https://polkadot.subscan.io/api/open/block"
    payload = "{\n\t\"block_num\": "+str(block)+"\n}"
    headers = {
      'Content-Type': 'application/json'
    }
    response = requests.request("POST", url, headers=headers, data = payload)
    
    if response.status_code == 200:
        return datetime.utcfromtimestamp(response.json()['data']['block_timestamp'])


for file in os.listdir():
    if fnmatch.fnmatch(file, r'reward*.csv'):
        print("Processing ", file)
        df = pd.read_csv(file)
        df.Value = df.Value / 10e9
        df.Block = df.Block.apply(get_timestamp)
        df['Label'] = "Reward"
        df['Currency'] = "DOT"
        df = df.rename(columns={'Block': 'Koinly Date', 'Value': 'Amount', 'Extrinsic Hash': 'TxHash'})
        df[['Koinly Date', 'Amount', 'Currency', 'Label', 'TxHash']].to_csv("{}_koinly.csv".format(file), index = False)
    if fnmatch.fnmatch(file, r'transfer*.csv'):
        print("Processing ", file)
        df = pd.read_csv(file)
        df.Block = df.Block.apply(get_timestamp)
        df['Currency'] = "DOT"
        df['Description'] = df.apply(lambda x: "Transfer from {} to {}".format(x["From"], x["To"]), axis = 1)
        df = df.rename(columns={'Block': 'Koinly Date', 'Value': 'Amount', 'Hash': 'TxHash'})
        df[['Koinly Date', 'Amount', 'Currency', 'Description', 'TxHash']].to_csv("{}_koinly.csv".format(file), index = False)

EDIT: Minor change to fix localized timestamps

Both Polkadot and Kusama have been released.

2 Likes