-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzenocean.py
75 lines (66 loc) · 3.17 KB
/
zenocean.py
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
import os
from web3 import Web3
from ocean_lib.ocean.ocean import Ocean
from ocean_lib.config import Config
from ocean_lib.config import Config
from ocean_lib.config_provider import ConfigProvider
from ocean_lib.ocean.util import get_web3_connection_provider
from ocean_lib.web3_internal.web3_provider import Web3Provider, CustomHTTPProvider
from ocean_lib.data_provider.data_service_provider import DataServiceProvider
from ocean_utils.agreements.service_factory import ServiceDescriptor
from ocean_lib.web3_internal.contract_handler import ContractHandler
from ocean_lib.web3_internal.wallet import Wallet
def run_scenario():
config = Config('config.ini')
ocean = Ocean(config)
wallet = Wallet(ocean.web3, 0x376e05899a4ae00463a3a607c774069b7d6a647860dba723f39b735c91238ddf, None, "EARLYTOBEDANDEARLYTORISE")
ConfigProvider.set_config(config)
Web3Provider.init_web3(provider=get_web3_connection_provider(config.network_url))
ContractHandler.set_artifacts_path(config.artifacts_path)
print(dir(wallet))
print(wallet.address)
print(config.network_url)
print(config.provider_url)
print(config.network_url)
print(config.artifacts_path)
data_token = ocean.create_data_token('S1Seven', 'S1SV', from_wallet=wallet)
print(f'created new datatoken with address {data_token.address}')
token_address = data_token.address
print(token_address)
'''
date_created = "2020-12-01T10:55:11Z"
service_attributes = {
"main": {
"name": "dataAssetAccessServiceAgreement",
"creator": wallet.address,
"timeout": 3600 * 24,
"datePublished": date_created,
"cost": 1.0, # <don't change, this is obsolete>
}
}
service_endpoint = DataServiceProvider.get_url(ocean.config)
download_service = ServiceDescriptor.access_service_descriptor(service_attributes, service_endpoint)
metadata = {
"main": {
"type": "dataset", "name": "S1Seven", "author": "Hannes",
"license": "CC0: Public Domain", "dateCreated": date_created,
"files": [
{ "index": 0, "contentType": "application/zip", "url": "https://s3.amazonaws.com/datacommons-seeding-us-east/10_Monkey_Species_Small/assets/training.zip"},
{ "index": 1, "contentType": "text/text", "url": "https://s3.amazonaws.com/datacommons-seeding-us-east/10_Monkey_Species_Small/assets/monkey_labels.txt"},
{ "index": 2, "contentType": "application/zip", "url": "https://s3.amazonaws.com/datacommons-seeding-us-east/10_Monkey_Species_Small/assets/validation.zip"}]}
}
asset = ocean.assets.create(metadata, wallet, service_descriptors=[download_service], data_token_address=token_address)
assert token_address == asset.data_token_address
did = asset.did
print(did)
data_token.mint_tokens(wallet.address, 100.0, wallet)
print(data_token.address)
pool = ocean.pool.create(
token_address,
data_token_amount=20.0,
OCEAN_amount=2.0,
from_wallet=wallet
)
pool_address = pool.address
print(f'DataToken @{data_token.address} has a `pool` available @{pool_address}')
'''