Day 7 of #100DaysOfCode - Continuing the Two Week Trend

Welp, at least I can be consistently inconsistent. I am being told that Monday will be the last day of this particular engagement, so I expect to work most of the weekend, and then returning to more reasonable hous afterwards. Woo...

Tracker

I've been messing around here with the Tracker, and I think I've come up with something that I'm pretty content with.

Maybe someone could tell me if this is horribly convoluted.

So I have my favorites listed out, along with the balances on each platform:

token_favorites = {
    "CUB": {
        "network": "Binance Smart Chain",
        "network-url": "binance-smart-chain",
        "token contract address": "0x50d809c74e0b8e49e7b4c65bb3109abe3ff4c1c1",
        "holdings": {
            "CubFinance": 1300.445,
            "Coinbase Pro": 821,
        }
    },
    "wLEO": {
        "network": "Ethereum",
        "network-url": "ethereum",
        "token contract address": "0x73a9fb46e228628f8f9bb9004eca4f4f529d3998",
        "holdings": {
            "CubFinance": 100.445,
            "Binance.com": 20,
            "Coinbase": 5,
            "KuCoin": 10,
        }
    }
}

I was running into issues with pulling information out of the nested dictionary, as dictionaries seem to require using the actual key, and not an index (like with lists)

My solution was to use list(token_favorites.keys()) to convert the keys of the dictionary into a list, followed by a counter, to have token_favorites_name be equal to the name of the token.

This same logic was then applied to each of the exchanges.

for range in (0,len(token_favorites)):
    token_favorites_name = list(token_favorites.keys())[token_counter]
    token_favorites_holdings = token_favorites[token_favorites_name]['holdings']
    token_favorites_exchange = list(token_favorites_holdings.keys())[exchange_counter]

    token_price = favorites_price_request(token_favorites[token_favorites_name]['network-url'],token_favorites[token_favorites_name]['token contract address'])

    print(f"You have {token_favorites_holdings[token_favorites_exchange]} ${token_favorites_name} on {token_favorites_exchange}, which is equal to ${round(token_price * token_favorites_holdings[token_favorites_exchange],2)}.")

    while len(list(token_favorites_holdings.keys())) > (exchange_counter + 1):
        exchange_counter = exchange_counter + 1
        token_favorites_exchange = list(token_favorites_holdings.keys())[exchange_counter]
        print(f"You have {token_favorites_holdings[token_favorites_exchange]} ${token_favorites_name} on {token_favorites_exchange}, which is equal to ${round(token_price * token_favorites_holdings[token_favorites_exchange],2)}.")
    
    token_counter = token_counter + 1

This gives me a pretty clean output:

You have 1300.445 $CUB on CubFinance, which is equal to $2106.72.
You have 821 $CUB on Coinbase Pro, which is equal to $1330.02.
You have 20 $wLEO on Binance.com, which is equal to $10.83.
You have 5 $wLEO on Coinbase, which is equal to $2.71.
You have 10 $wLEO on KuCoin, which is equal to $5.41.

I think this is pretty good for now. I think my next step would be to figure out how I can go about inputting transactions, and having the balances automatically update based on what I input. Ideally, I could input something like 'deposit 100 USD on Coinbase Pro' followed by 'swap 100 USD for 159 XLM on Coinbase Pro' and have it all work out nicely.

Turtle

I've been paying more and more attention to NFTs, for better or for worse. I find a lot of the way games have incorporated NFTs to be fascinating, but I've also been looking at artwork recently.

I've been thinking of trying to make some sort of algorithmic art series, similar to what CryptoPunks did. Turtle seems to be able to do this decently well, and I found a tutorial for creating some pixel art. The tutorial uses a list of list to make a grid that you input 0s and 1s in to create your pixel art.

So, you go and input something like this:

pixels     = [[0,0,0,0,1,0,0,1,0,0,1,0,0,0,0]]
pixels.append([0,0,0,1,1,1,0,0,1,0,0,1,0,0,0])
pixels.append([0,0,0,1,1,1,0,0,1,0,0,1,0,0,0])
pixels.append([0,0,1,1,1,1,1,0,0,1,0,0,1,0,0])
pixels.append([0,0,1,1,1,1,1,0,0,1,0,0,1,0,0])
pixels.append([0,1,1,1,1,1,1,1,0,0,1,0,0,1,0])
pixels.append([0,1,1,1,1,1,1,1,0,0,0,0,0,1,0])
pixels.append([1,1,1,1,1,1,1,1,1,0,0,0,0,0,1])
pixels.append([0,1,1,1,1,1,1,1,0,0,0,0,0,1,0])
pixels.append([0,1,1,1,1,1,1,1,0,0,1,0,0,1,0])
pixels.append([0,0,1,1,1,1,1,0,0,1,0,0,1,0,0])
pixels.append([0,0,1,1,1,1,1,0,0,1,0,0,1,0,0])
pixels.append([0,0,0,1,1,1,0,0,1,0,0,1,0,0,0])
pixels.append([0,0,0,1,1,1,0,0,1,0,0,1,0,0,0])
pixels.append([0,0,0,0,1,0,0,1,0,0,1,0,0,0,0])

And then end up with this:

image.png

Change the color and then you'll have:

image.png

This is pretty damn cool I would say! I think I could actually make this work, but I would have create a base layer, and then add on... 'accessories' which would replace 0's and 1's accordingly. I'll also have to think about how changing colors would work.

Anyway, that's pretty much it for now. Hopefully Day 8 will be on Tuesday the latest, and not two weeks from now. 🤞



0
0
0.000
1 comments
avatar

Congratulations @phul! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You published more than 30 posts.
Your next target is to reach 40 posts.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out the last post from @hivebuzz:

Hive Tour Update - Decentralized blacklists and Mutes lists
Support the HiveBuzz project. Vote for our proposal!
0
0
0.000