File size: 2,842 Bytes
bf7868e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import os
from dotenv import load_dotenv
import gradio
from substrateinterface import SubstrateInterface, Keypair, MnemonicLanguageCode, KeypairType
from decimal import Decimal, getcontext
from mexc_sdk import Spot
import requests





load_dotenv()
key = os.getenv("COINMARKKETCAP_API_KEY")
mexc_client = Spot(api_key=os.getenv('MEXC_ACCESS_KEY'),api_secret=os.getenv('MEXC_SECRET_KEY'))



rpc_url = SubstrateInterface(url="wss://rpc-parachain.bajun.network")
# substrate = SubstrateInterface(url="ws://127.0.0.1:9944")
# etat = local_host.isConnected()
# print(etat)

# ymc_address = ['5G6s3tvwCbQ7MZWYmUrZkG8iYxYwAG8usqM57yJF8bU8Dbvr']






def salut(name) :
    print(name)
    return f"Salut !!! {name}"


def get_balance(address) :

    url = "https://www.mexc.com/open/api/v2/market/ticker?symbol=BAJU_USDT"
    reponse = requests.get(url)
    data = reponse.json()
    prix_baju = float(data['data'][0]['last'])
    getcontext().prec = 15
    result = rpc_url.query('System', 'Account', [address])
    balance = Decimal(result.value['data']['free']) / Decimal(10 ** 12)
    balance_format = float(format(balance, '.2f'))
    # print(type(result.value['data']['free']))
    print(address)
    balance_usd = prix_baju * balance_format
    return f"Votre Balance est de : {balance_format} Bajun  ~ {balance_usd:.2f}$ USD"


print(rpc_url.get_chain_head())

description2 = 'h1 style="font-size:50px;text-align:center;"> Bajun Balanc Checker</h1>'
description = "Bajun Balance Checker ^^"
desk = "Mogwai Wallet checker 0.0.1 "


with gradio.Blocks(title="Mogwai Wallet Checker..by YmC") as app :
    title = gradio.Label(description,label=desk)
    adresse = gradio.Textbox(label="enter your address")
    nom = gradio.Textbox(label="enter your name or not ")
    balance_output = gradio.Textbox(label="Balance")
    run_button = gradio.Button("RUN")
    salut_button = gradio.Button("Say Holla To YmC ^^ ")
    run_button.click(fn=get_balance, inputs=adresse, outputs=balance_output)
    salut_button.click(fn=salut, inputs=nom, outputs=balance_output)

    app.launch(share=True,debug=True)

# get_balance(liste_address[0])
# get_balance(ymc_address[0])

# def transfer(dest):
#     call = rpc_url.compose_call(
#         call_module='Balances',
#         call_function='transfer',
#         call_params={
#             'dest': dest,
#             'value': 1 * 10 ** 15
#         }
#     )
#     keypair = Keypair.create_from_uri('//Alice')
#     extrinsic = rpc_url.create_signed_extrinsic(call=call, keypair=keypair)
#     recu = rpc_url.submit_extrinsic(extrinsic, wait_for_inclusion=True)
#
#     print(f"extrinsic : '{recu.extrinsic_hash}")
#     print(f"Block Hash: {recu.block_hash}")
#     print(f"Block Number: {recu.block_number}")
#
#
# print()

# for balance in liste_address:
#     print(f'{get_balance(balance)} Bajun ')