-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_knowledge_asset.py
89 lines (75 loc) · 2.34 KB
/
create_knowledge_asset.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import json
from dotenv import load_dotenv
import os
from dkg import DKG
from dkg.providers import BlockchainProvider, NodeHTTPProvider
load_dotenv()
def divider():
print("==================================================")
print("==================================================")
print("==================================================")
def print_json(json_dict: dict):
print(json.dumps(json_dict, indent=4))
node_provider = NodeHTTPProvider("https://v8-testnet-09.origin-trail.network:8900")
blockchain_provider = BlockchainProvider(
"testnet",
"base:84532",
private_key=os.getenv("PRIVATE_KEY"),
)
dkg = DKG(node_provider, blockchain_provider)
content = {
"public": {
"@context": "https://schema.org",
"@type": "Event",
"name": "DKGCon 2024",
"description": "The Decentralized Knowledge Conference (DKGCon).",
"location": {
"@type": "Place",
"name": "Sam's Koffie",
"address": {
"@type": "PostalAddress",
"streetAddress": "Meeuwenlaan 126B",
"addressLocality": "Amsterdam",
"addressRegion": "NH",
"postalCode": "1021 JN",
"addressCountry": "NL"
}
},
"subEvent": {
"@type": "Event",
"name": "Workshop #1",
"description": "A workshop focused on the basics of the DKG.",
"performer": [
{
"@type": "Person",
"name": "Branimir Rakic",
"jobTitle": "CTO"
},
{
"@type": "Person",
"name": "Uladzislau Hubar",
"jobTitle": "Protocols Engineer"
}
]
},
"keywords": [
"Decentralized Knowledge",
"Blockchain",
"Web3",
"OriginTrail",
"Digital Trust"
],
},
}
info_result = dkg.node.info
print("======================== NODE INFO RECEIVED")
print_json(info_result)
divider()
create_asset_result = dkg.asset.create(content, 2)
print("======================== ASSET CREATED")
print_json(create_asset_result)
divider()
get_asset_result = dkg.asset.get(create_asset_result["UAL"])
print("======================== ASSET RESOLVED")
print_json(get_asset_result)
divider()