zackxiaoming / chartWTF

Charting
0 stars 0 forks source link

Fetch all token from BSC SCAN #1

Open zackxiaoming opened 2 years ago

zackxiaoming commented 2 years ago

Task1: Fetch all BEP20 - name, contract address from BscScan that interact with PancakeSwap for past 1000 blocks.

Task2: Fetch all token buy/sell activities with PancakeSwap

Transact Time Type > BNB or BUSD BNB Amount / BUSD Amount Transact amount in USD Initiate address

gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 1.0 BNB (197.34 USD @ $197.34/BNB) has been submitted by:

  1. @developerfred

@zackxiaoming please take a look at the submitted work:


CriptKeeper commented 2 years ago

Hello @zackxiaoming, I saw this bounty on Gitcoin and was curious if it's still open to work on? It looks like developerfred may have completed it already, but if not I could finish that today.

hasankhadra commented 2 years ago

Hello @zackxiaoming ! Is the bounty still open?

mitesh-mutha commented 2 years ago

Hello @zackxiaoming is this bounty still open? I would love to pick it up if that's the case. I have experience doing similar things and will be able to complete this easily and fairly quickly.

developerfred commented 1 year ago

Be careful when working on this reward

voermx commented 1 year ago

Task 1:

import requests

    # Replace <pancakeSwap_address> and <your_api_key> with actual values
    url = "https://bscscan.com/api?module=account&action=tokentx&address=<pancakeSwap_address>&sort=asc&apikey=<your_api_key>"

    response = requests.get(url)
    data = response.json()

    bep20_tokens = []
    for tx in data["result"]:
        if tx["contractAddress"] not in [token["contractAddress"] for token in bep20_tokens]:
            bep20_tokens.append({"name": tx["tokenName"], "contractAddress": tx["contractAddress"]})

    print(bep20_tokens)

Task 2:

import json

    # Replace <pancakeSwap_address> and <your_api_key> with actual values
    url = "https://bscscan.com/api?module=account&action=tokentx&address=<pancakeSwap_address>&sort=asc&apikey=<your_api_key>"

    response = requests.get(url)
    data = response.json()

    # Fetch USD value of BNB and BUSD
    bnb_usd_url = "https://api.coingecko.com/api/v3/simple/price?ids=binance-coin&vs_currencies=usd"
    busd_usd_url = "https://api.coingecko.com/api/v3/simple/price?ids=binance-usd&vs_currencies=usd"
    bnb_usd_response = requests.get(bnb_usd_url)
    busd_usd_response = requests.get(busd_usd_url)
    bnb_usd_data = bnb_usd_response.json()
    busd_usd_data = busd_usd_response.json()
    bnb_usd_value = bnb_usd_data["binance-coin"]["usd"]
    busd_usd_value = busd_usd_data["binance-usd"]["usd"]

    buy_sell_data = []
    for tx in data["result"]:
        if tx["tokenSymbol"] in ["BNB", "BUSD"]:
            if tx["tokenSymbol"] == "BNB":
                usd_value = bnb_usd_value * float(tx["value"])
            else:
                usd_value = busd_usd_value * float(tx["value"])
            buy_sell_data.append({"Transaction Time": tx["timeStamp"], 
                                  "Token": tx["tokenSymbol"], 
                                  "Amount": tx["value"], 
                                  "Transaction amount in USD": usd_value,
                                  "Initiate address": tx["from"]})

    print(json.dumps(buy_sell_data))