File size: 4,105 Bytes
19e145e
1f36683
 
 
 
 
 
1f462ce
19e145e
1f36683
 
19e145e
0747d89
273fb6c
 
 
1f36683
 
 
 
e82d1af
1f36683
 
e82d1af
1f36683
eb33e84
1f36683
 
eb33e84
1f36683
eb33e84
1f36683
19e145e
 
8c7a87b
1f08bf7
8c7a87b
 
 
 
eb33e84
 
1f08bf7
 
19e145e
 
 
 
1f08bf7
 
36ffca7
1f08bf7
 
36ffca7
19e145e
 
 
e82d1af
19e145e
273fb6c
0747d89
 
 
8b20f20
273fb6c
 
 
 
 
 
8b20f20
dc6935a
19e145e
 
 
 
 
 
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
import gradio as gr
# from ocean_lib.config import Config
# from ocean_lib.models.btoken import BToken #BToken is ERC20
# from ocean_lib.ocean.ocean import Ocean
# from ocean_lib.web3_internal.wallet import Wallet
# from ocean_lib.web3_internal.currency import from_wei # wei is the smallest denomination of ether e.g. like cents
# from ocean_lib.web3_internal.currency import pretty_ether_and_wei
from wallet import get_wallet

# config = Config('config.ini')
# ocean = Ocean(config)

def w(hello):
    account, mnemonic = get_wallet()
    return account, mnemonic

# def wallet(private_key, did):
#     wallet = Wallet(ocean.web3, private_key, transaction_timeout=20, block_confirmations=config.block_confirmations)
#     address = wallet.address
#     OCEAN_token = BToken(ocean.web3, ocean.OCEAN_address)

#     eth_balance = from_wei(ocean.web3.eth.get_balance(wallet.address))
#     ocean_balance = from_wei(OCEAN_token.balanceOf(wallet.address))

#     asset = ocean.assets.resolve(did)

#     ALG_ddo = ocean.assets.resolve(did)
#     alg_token = ocean.get_data_token(ALG_ddo.data_token_address)

#     alg_token_balance = pretty_ether_and_wei(alg_token.balanceOf(wallet.address))

#     return address, eth_balance, ocean_balance, alg_token_balance

description = (
    "This demo shows the balance of algorithm tokens, as well as ETH and OCEAN, in your Web3 wallet (for a given private key). The algorithm tokens will be used to run Algovera apps on HF spaces in future. " 
    "Currently, you need to export your private key from a MetaMask wallet (we plan to randomly generate a private key in the app and bypass MetaMask in future). "
    "For a guide on how to install MetaMask (an extension in your browser), check the link at the bottom of the page. "
    "We highly recommend doing this with a wallet that has no real tokens in it. We use a test network (Rinkeby) where the tokens have no real value. "
    "After an initial setup, your wallet should have no tokens. You can request ETH and OCEAN test tokens from faucets at the links at the bottom of the page. "
    "To buy an algorithm token (using the OCEAN and ETH), you can search for algorithms on the Ocean marketplace (see link at bottom). Make sure to use algorithms that are on the Rinkeby test network (you need to select Rinkeby from the dropdown menu). "
    "We have provided a link to our DCGAN model on the test network at the bottom. If you can't see it you are not on the test network. "
    "After you buy an algorithm token, you need to locate the DID in the metadata on the marketplace. Then enter it into the input textbox. "
    "Later we will add HF Spaces apps to search algorithms and buy algorithm tokens, which you can use to run demos of the algorithms. "
    "This demo uses the Ocean Python library in the backend (see link below)."
)

article = (
    "<p style='text-align: center'>"
    "<a href='https://docs.oceanprotocol.com/tutorials/metamask-setup/' target='_blank'>1. Guide for installing MetaMask</a> | "
    "<a href='https://faucet.rinkeby.io/' target='_blank'>2. ETH faucet</a> | "
    "<a href='https://faucet.rinkeby.oceanprotocol.com/' target='_blank'>3. OCEAN faucet | </a>"
    "<a href='https://market.oceanprotocol.com/' target='_blank'>4. Ocean marketplace</a> | "
    "<a href='https://market.oceanprotocol.com/asset/did:op:E2e123115d5758Dd4C6F434E1c142e72ed8B2820' target='_blank'>5. DCGAN algorithm</a> | "
    "<a href='https://github.com/oceanprotocol/ocean.py' target='_blank'>6. Ocean Python Library</a>"
    "</p>"
)


interface = gr.Interface(
    w,
    [
        gr.inputs.Textbox(label="Greetings"),
    ],
    [
        #gr.outputs.Textbox(label="Public Key"),
        #gr.outputs.Textbox(label="ETH balance"),
        #gr.outputs.Textbox(label="OCEAN balance"),
        #gr.outputs.Textbox(label="Algorithm token balance"),
        gr.outputs.Textbox(label="Account Address"),
        gr.outputs.Textbox(label="Recovery Passphrase"),
    ],
    title="Algorithm Web3 Wallet",
    description=description,
    article=article,
    theme="huggingface",
)

interface.launch()