Spaces:
Runtime error
Runtime error
Commit
·
210a945
1
Parent(s):
72c21f4
show ETH and OCEAN balance
Browse files
app.py
CHANGED
@@ -1,18 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
# from ocean_lib.web3_internal.currency import pretty_ether_and_wei
|
8 |
from wallet import get_wallet
|
9 |
|
10 |
-
|
11 |
-
|
12 |
|
13 |
-
def
|
14 |
account, mnemonic = get_wallet()
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
# def wallet(private_key, did):
|
18 |
# wallet = Wallet(ocean.web3, private_key, transaction_timeout=20, block_confirmations=config.block_confirmations)
|
@@ -57,17 +68,17 @@ article = (
|
|
57 |
|
58 |
|
59 |
interface = gr.Interface(
|
60 |
-
|
61 |
[
|
62 |
gr.inputs.Textbox(label="Greetings"),
|
63 |
],
|
64 |
[
|
65 |
#gr.outputs.Textbox(label="Public Key"),
|
66 |
-
#gr.outputs.Textbox(label="ETH balance"),
|
67 |
-
#gr.outputs.Textbox(label="OCEAN balance"),
|
68 |
#gr.outputs.Textbox(label="Algorithm token balance"),
|
69 |
gr.outputs.Textbox(label="Account Address"),
|
70 |
gr.outputs.Textbox(label="Recovery Passphrase"),
|
|
|
|
|
71 |
],
|
72 |
title="Algorithm Web3 Wallet",
|
73 |
description=description,
|
|
|
1 |
import gradio as gr
|
2 |
+
from ocean_lib.config import Config
|
3 |
+
from ocean_lib.models.btoken import BToken #BToken is ERC20
|
4 |
+
from ocean_lib.ocean.ocean import Ocean
|
5 |
+
from ocean_lib.web3_internal.wallet import Wallet
|
6 |
+
from ocean_lib.web3_internal.currency import from_wei # wei is the smallest denomination of ether e.g. like cents
|
7 |
# from ocean_lib.web3_internal.currency import pretty_ether_and_wei
|
8 |
from wallet import get_wallet
|
9 |
|
10 |
+
config = Config('config.ini')
|
11 |
+
ocean = Ocean(config)
|
12 |
|
13 |
+
def wallet(hello):
|
14 |
account, mnemonic = get_wallet()
|
15 |
+
|
16 |
+
private_key = account.key
|
17 |
+
address = account.address
|
18 |
+
|
19 |
+
wallet = Wallet(ocean.web3, private_key, transaction_timeout=20, block_confirmations=config.block_confirmations)
|
20 |
+
|
21 |
+
OCEAN_token = BToken(ocean.web3, ocean.OCEAN_address)
|
22 |
+
|
23 |
+
eth_balance = from_wei(ocean.web3.eth.get_balance(address))
|
24 |
+
ocean_balance = from_wei(OCEAN_token.balanceOf(address))
|
25 |
+
|
26 |
+
return address, mnemonic, eth_balance, ocean_balance
|
27 |
|
28 |
# def wallet(private_key, did):
|
29 |
# wallet = Wallet(ocean.web3, private_key, transaction_timeout=20, block_confirmations=config.block_confirmations)
|
|
|
68 |
|
69 |
|
70 |
interface = gr.Interface(
|
71 |
+
wallet,
|
72 |
[
|
73 |
gr.inputs.Textbox(label="Greetings"),
|
74 |
],
|
75 |
[
|
76 |
#gr.outputs.Textbox(label="Public Key"),
|
|
|
|
|
77 |
#gr.outputs.Textbox(label="Algorithm token balance"),
|
78 |
gr.outputs.Textbox(label="Account Address"),
|
79 |
gr.outputs.Textbox(label="Recovery Passphrase"),
|
80 |
+
gr.outputs.Textbox(label="ETH balance"),
|
81 |
+
gr.outputs.Textbox(label="OCEAN balance"),
|
82 |
],
|
83 |
title="Algorithm Web3 Wallet",
|
84 |
description=description,
|