Skip to content

Commit 05e4a41

Browse files
Merge pull request #1 from hiero-ledger/chore/update-readme
Restructure docs and update README
2 parents 7c069f6 + 0c9c54c commit 05e4a41

File tree

4 files changed

+203
-19
lines changed

4 files changed

+203
-19
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Now, validate that all unit tests are passing:
103103
make test
104104
```
105105

106-
9. Before raising a pull request you should also run tox.
106+
9. Before raising a pull request it's recommended to also run tox.
107107
This will run the tests across different versions of Python:
108108

109109
```bash

README.md

Lines changed: 193 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@
99
The repository contains the Python SDK for managing DID Documents and AnonCreds Verifiable Credentials registry using
1010
Hedera Consensus Service.
1111

12-
Documentation:
12+
This library is using [Hiero Python SDK](https://github.com/hiero-ledger/hiero-sdk-python).
1313

14-
- ~~See [SDK docs](https://hiero-ledger.github.io/hiero-did-sdk-python/)~~
15-
- Not published yet, see [src in repo](docs/dev)
16-
- Design documentation can be found in [repo folder](docs/design)
14+
## Documentation
1715

18-
## Getting started
16+
### Dev and API
1917

20-
### Prerequisites
18+
We're planning to publish dev guides along with [mkdocs](https://www.mkdocs.org/)-generated API documentation to GH pages in near future.
19+
You can find [documentation sources in repo](docs/dev).
2120

22-
- Python 3.12+
23-
- [Poetry](https://python-poetry.org/) (at least 1.8.4)
24-
- NodeJS and npm (used by pre-commit hooks)
25-
- Tools for Makefile support (Windows only)
26-
- Can be installed with [chocolatey](https://chocolatey.org/): `choco install make`
21+
Meanwhile, dev guides have been added to this README for convenience.
22+
23+
If you're planning to contribute to the project, please also check [contribution guidelines](CONTRIBUTING.md).
24+
25+
### Design
2726

28-
### Environment
27+
SDK design documentation can be found in corresponding [repo folder](docs/design).
28+
29+
## Dev environment
2930

3031
The project uses Makefile for dev scripts. You can view available commands by running:
3132

@@ -59,7 +60,184 @@ make test
5960
make build
6061
```
6162

62-
## Releasing a new version
63+
## Getting started
64+
65+
### Prerequisites
66+
67+
- Python 3.12+
68+
- [Poetry](https://python-poetry.org/) (at least 1.8.4)
69+
- NodeJS and npm (used by pre-commit hooks)
70+
- Tools for Makefile support (Windows only)
71+
- Can be installed with [chocolatey](https://chocolatey.org/): `choco install make`
72+
73+
### Install package (from Git source)
74+
75+
```bash
76+
pip install git+https://github.com/hiero-ledger/hiero-did-sdk-python@main
77+
```
78+
79+
Please note that PyPi package will soon be published and replace Git source dependency as recommended installation method.
80+
81+
### Example usage
82+
83+
Here you can find basic SDK usage examples.
84+
85+
For more complex examples, please refer to SDK integration tests:
86+
87+
- [Hedera DID](https://github.com/hiero-ledger/hiero-did-sdk-python/blob/main/tests/integration/test_hedera_did.py)
88+
- [AnonCreds registry](https://github.com/hiero-ledger/hiero-did-sdk-python/blob/main/tests/integration/test_hedera_anoncreds_registry.py)
89+
90+
#### Create Hedera Client (for testnet)
91+
92+
```python
93+
from hiero_sdk_python import Client, Network, AccountId, PrivateKey
94+
95+
client = Client(
96+
network=Network("testnet")
97+
)
98+
99+
client.set_operator(AccountId.from_string("OPERATOR_ID"), private_key=PrivateKey.from_string("OPERATOR_KEY"))
100+
```
101+
102+
#### Register new Hedera DID on testnet network and add DID service
103+
104+
```python
105+
from hiero_did_sdk_python import HederaDid
106+
107+
did = HederaDid(client=client, private_key_der="private_key_der")
108+
109+
await did.register()
110+
111+
await did.add_service(
112+
id_=f"{did.identifier}#service-1", service_type="LinkedDomains", service_endpoint="https://example.com/vcs"
113+
)
114+
```
115+
116+
#### Resolve existing Hedera DID
117+
118+
```python
119+
from hiero_did_sdk_python import HederaDidResolver
120+
121+
resolver = HederaDidResolver(client)
122+
123+
resolution_result = await resolver.resolve(
124+
"did:hedera:testnet:zvAQyPeUecGck2EsxcsihxhAB6jZurFrBbj2gC7CNkS5o_0.0.5063027")
125+
```
126+
127+
#### Create AnonCreds credential schema and credential definition
128+
129+
```python
130+
from hiero_did_sdk_python import HederaAnonCredsRegistry, AnonCredsSchema, AnonCredsCredDef, CredDefValue, CredDefValuePrimary
131+
132+
issuer_did = "did:hedera:testnet:zvAQyPeUecGck2EsxcsihxhAB6jZurFrBbj2gC7CNkS5o_0.0.5063027"
133+
registry = HederaAnonCredsRegistry(client)
134+
135+
schema = AnonCredsSchema(
136+
name="schema-name",
137+
issuer_id=issuer_did,
138+
attr_names=["name", "age"],
139+
version="1"
140+
)
141+
142+
schema_registration_result = await registry.register_schema(schema, issuer_did, "OPERATOR_KEY_DER")
143+
144+
cred_def = AnonCredsCredDef(
145+
schema_id=schema_registration_result.schema_state.schema_id,
146+
issuer_id=issuer_did,
147+
value=CredDefValue(primary=CredDefValuePrimary(...)),
148+
tag="cred-def-tag"
149+
)
150+
151+
cred_def_registration_result = await registry.register_cred_def(cred_def, issuer_did, "OPERATOR_KEY_DER")
152+
```
153+
154+
## Configuration
155+
156+
At the moment, SDK comes with following configuration capabilities:
157+
158+
- Hedera Client configuration
159+
- Cache implementation (optional)
160+
- Logger configuration (optional)
161+
162+
### Hedera Client configuration
163+
164+
Configuration consists from two parts:
165+
166+
- Network configuration
167+
- Basic configuration is lightweight and consists from selection of specific network ("mainnet", "testnet", "
168+
previewnet"), complex parts are handled by Hedera Python SDK
169+
- Custom configuration can be provided, if necessary
170+
- Hedera operator (account) configuration
171+
- Essentially, account "credentials" that will be used for Hedera network integration and paying fees
172+
- Needs to be provided explicitly and can be changed for specific Hedera Client instance via provider class
173+
174+
#### Examples
175+
176+
Create client for Testnet and set operator config:
177+
178+
```python
179+
from hiero_sdk_python import Client, Network, AccountId, PrivateKey
180+
181+
client = Client(
182+
network=Network("testnet")
183+
)
184+
185+
client.set_operator(AccountId.from_string("OPERATOR_ID"), private_key=PrivateKey.from_string("OPERATOR_KEY"))
186+
```
187+
188+
Create client provider with custom network config:
189+
190+
```python
191+
from hiero_sdk_python import Client, Network, AccountId, PrivateKey
192+
193+
TESTNET_NODES = [
194+
("0.testnet.hedera.com:50211", AccountId(0, 0, 3)),
195+
("1.testnet.hedera.com:50211", AccountId(0, 0, 4))
196+
]
197+
198+
client = Client(
199+
network=Network(network="testnet", nodes=TESTNET_NODES, mirror_address="hcs.testnet.mirrornode.hedera.com:5600"),
200+
)
201+
client.set_operator(AccountId.from_string("OPERATOR_ID"), private_key=PrivateKey.from_string("OPERATOR_KEY"))
202+
```
203+
204+
### Cache implementation
205+
206+
SDK utilizes cache to optimize read operations and provides an option to customize cache implementation (individually
207+
for each resolver instance).
208+
209+
By default, [in-memory cache implementation](https://github.com/hiero-ledger/hiero-did-sdk-python/blob/main/hiero_did_sdk_python/utils/cache.py#L112) is used.
210+
211+
You can create custom cache implementation by inheriting [Cache base class](https://github.com/hiero-ledger/hiero-did-sdk-python/blob/main/hiero_did_sdk_python/utils/cache.py#L25).
212+
Custom cache instance needs to be provided in resolver constructor arguments.
213+
214+
Classes that accept custom cache implementation:
215+
216+
- [HederaDidResolver](https://github.com/hiero-ledger/hiero-did-sdk-python/blob/main/hiero_did_sdk_python/did/hedera_did_resolver.py)
217+
- [HederaAnonCredsRegistry](https://github.com/hiero-ledger/hiero-did-sdk-python/blob/main/hiero_did_sdk_python/anoncreds/hedera_anoncreds_registry.py)
218+
219+
#### Example
220+
221+
```python
222+
from hiero_did_sdk_python import Cache, HederaDidResolver
223+
224+
class CustomCache(Cache):
225+
...
226+
227+
custom_cache_instance = CustomCache[str, object]()
228+
229+
resolver = HederaDidResolver(client, custom_cache_instance)
230+
```
231+
232+
### Logger configuration
233+
234+
Logger configuration supports following properties that can be set with environment variables:
63235

64-
- Create a [new release](https://github.com/hiero-ledger/hiero-did-sdk-python/releases/new) on GitHub
65-
- Create a new tag in the form `*.*.*`
236+
- Log level
237+
- Env variable name: `HEDERA_DID_SDK_LOG_LEVEL`
238+
- Currently supported values: "DEBUG", "INFO", "WARN", "ERROR"
239+
- Log format (in string representation)
240+
- Env variable name: `HEDERA_DID_SDK_LOG_FORMAT`
241+
- For log format pattern reference, please see Python docs:
242+
- [Formatter objects](https://docs.python.org/3/library/logging.html#formatter-objects)
243+
- [Log record attributes](https://docs.python.org/3/library/logging.html#logrecord-attributes)

docs/dev/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ By default, [in-memory cache implementation](modules/common.md#hiero_did_sdk_pyt
5858
You can create custom cache implementation by inheriting [Cache base class](modules/common.md#hiero_did_sdk_python.utils.cache.Cache).
5959
Custom cache instance needs to be provided in resolver constructor arguments.
6060

61-
Resolver classes that accept custom cache implementation:
61+
Classes that accept custom cache implementation:
6262

6363
- [HederaDidResolver](modules/did.md#hiero_did_sdk_python.did.hedera_did_resolver.HederaDidResolver)
6464
- [HederaAnonCredsRegistry](modules/anoncreds.md#hiero_did_sdk_python.anoncreds.hedera_anoncreds_registry.HederaAnonCredsRegistry)

docs/dev/getting-started.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
## Prerequisites
44

55
- Python 3.12+
6+
- [Poetry](https://python-poetry.org/) (at least 1.8.4)
7+
- NodeJS and npm (used by pre-commit hooks)
8+
- Tools for Makefile support (Windows only)
9+
- Can be installed with [chocolatey](https://chocolatey.org/): `choco install make`
610

7-
## Install from PyPi
11+
## Install package (from Git source)
812

913
```bash
10-
pip install hiero-did-sdk-python
14+
pip install git+https://github.com/hiero-ledger/hiero-did-sdk-python@main
1115
```
1216

17+
Please note that PyPi package will soon be published and replace Git source dependency as recommended installation method.
18+
1319
## Example usage
1420

1521
Here you can find basic SDK usage examples.

0 commit comments

Comments
 (0)