hippius 0.1.7__tar.gz → 0.1.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hippius-0.1.7 → hippius-0.1.10}/PKG-INFO +189 -9
- {hippius-0.1.7 → hippius-0.1.10}/README.md +188 -8
- {hippius-0.1.7 → hippius-0.1.10}/hippius_sdk/__init__.py +4 -0
- hippius-0.1.10/hippius_sdk/account.py +648 -0
- {hippius-0.1.7 → hippius-0.1.10}/hippius_sdk/cli.py +645 -445
- {hippius-0.1.7 → hippius-0.1.10}/hippius_sdk/client.py +1 -1
- {hippius-0.1.7 → hippius-0.1.10}/hippius_sdk/config.py +72 -1
- {hippius-0.1.7 → hippius-0.1.10}/hippius_sdk/ipfs.py +1 -1
- {hippius-0.1.7 → hippius-0.1.10}/hippius_sdk/substrate.py +252 -154
- hippius-0.1.10/hippius_sdk/utils.py +87 -0
- {hippius-0.1.7 → hippius-0.1.10}/pyproject.toml +1 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: hippius
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.10
|
4
4
|
Summary: Python SDK and CLI for Hippius blockchain storage
|
5
5
|
Home-page: https://github.com/thenervelab/hippius-sdk
|
6
6
|
Author: Dubs
|
@@ -67,7 +67,7 @@ client = HippiusClient()
|
|
67
67
|
# Or specify custom endpoints
|
68
68
|
client = HippiusClient(
|
69
69
|
ipfs_gateway="https://ipfs.io", # For downloads (default)
|
70
|
-
ipfs_api_url="https://
|
70
|
+
ipfs_api_url="https://store.hippius.network", # For uploads (default)
|
71
71
|
)
|
72
72
|
|
73
73
|
# Upload a file to IPFS
|
@@ -313,6 +313,64 @@ This command provides detailed information about each erasure-coded file includi
|
|
313
313
|
- Miners storing the file
|
314
314
|
- Reconstruction command
|
315
315
|
|
316
|
+
The `ec-files` command is optimized for performance through parallel processing and intelligent filtering, making it efficient even with large numbers of files.
|
317
|
+
|
318
|
+
#### Performance Considerations
|
319
|
+
|
320
|
+
The erasure coding implementation has been optimized for:
|
321
|
+
|
322
|
+
1. **Speed**: Parallel processing for file operations
|
323
|
+
2. **Memory efficiency**: Files are processed in chunks to minimize memory usage
|
324
|
+
3. **Auto-tuning**: Parameters like chunk size are automatically adjusted for small files
|
325
|
+
4. **Intelligent filtering**: The system can quickly identify potential erasure-coded files
|
326
|
+
|
327
|
+
For extremely large files (>1GB), consider using larger chunk sizes to improve performance:
|
328
|
+
|
329
|
+
```bash
|
330
|
+
hippius erasure-code large_video.mp4 --chunk-size 10485760 # 10MB chunks
|
331
|
+
```
|
332
|
+
|
333
|
+
#### Directory Support for Erasure Coding
|
334
|
+
|
335
|
+
Hippius SDK now supports applying erasure coding to entire directories:
|
336
|
+
|
337
|
+
```bash
|
338
|
+
# Apply erasure coding to an entire directory
|
339
|
+
hippius erasure-code my_directory/
|
340
|
+
|
341
|
+
# The CLI will detect that it's a directory and offer two options:
|
342
|
+
# 1. Archive the directory first, then erasure code the archive
|
343
|
+
# 2. Apply erasure coding to each file in the directory individually
|
344
|
+
```
|
345
|
+
|
346
|
+
When choosing the second option, the system will process each file in the directory individually, adjusting parameters like chunk size automatically for small files. A summary of the operation will be displayed, showing:
|
347
|
+
- Total files processed
|
348
|
+
- Successfully coded files with their metadata CIDs
|
349
|
+
- Any files that failed, with error details
|
350
|
+
|
351
|
+
To reconstruct a file from erasure-coded chunks:
|
352
|
+
|
353
|
+
```bash
|
354
|
+
hippius reconstruct QmMetadataCID reconstructed_filename
|
355
|
+
```
|
356
|
+
|
357
|
+
#### Default Address Management
|
358
|
+
|
359
|
+
Hippius SDK now allows setting a default address for read-only operations, making it easier to use commands like `files` and `ec-files` without specifying an account address each time:
|
360
|
+
|
361
|
+
```bash
|
362
|
+
# Set a default address for read-only operations
|
363
|
+
hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
|
364
|
+
|
365
|
+
# View the currently set default address
|
366
|
+
hippius address get-default
|
367
|
+
|
368
|
+
# Clear the default address
|
369
|
+
hippius address clear-default
|
370
|
+
```
|
371
|
+
|
372
|
+
Once a default address is set, commands like `hippius files` and `hippius ec-files` will automatically use this address when no explicit address is provided.
|
373
|
+
|
316
374
|
#### Troubleshooting
|
317
375
|
|
318
376
|
1. **IPFS Connection Issues**: Make sure you have either:
|
@@ -333,7 +391,30 @@ This command provides detailed information about each erasure-coded file includi
|
|
333
391
|
which hippius
|
334
392
|
```
|
335
393
|
|
336
|
-
4. **
|
394
|
+
4. **Default Address Issues**: If you receive errors about missing account address:
|
395
|
+
```bash
|
396
|
+
# Set a default address for read-only operations
|
397
|
+
hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
|
398
|
+
```
|
399
|
+
|
400
|
+
5. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
|
401
|
+
|
402
|
+
6. **Erasure Coding Problems**:
|
403
|
+
- **"Wrong length for input blocks"**: This typically happens with very small files
|
404
|
+
```bash
|
405
|
+
# Try smaller k and m values for small files
|
406
|
+
hippius erasure-code small_file.txt --k 2 --m 3
|
407
|
+
```
|
408
|
+
- **Directories can't be directly coded**: Use the directory support option when prompted
|
409
|
+
- **"zfec is required"**: Install the missing package
|
410
|
+
```bash
|
411
|
+
pip install zfec
|
412
|
+
poetry add zfec
|
413
|
+
```
|
414
|
+
- **Slow performance with large files**: Increase chunk size
|
415
|
+
```bash
|
416
|
+
hippius erasure-code large_file.mp4 --chunk-size 5242880 # 5MB chunks
|
417
|
+
```
|
337
418
|
|
338
419
|
## Command Line Interface
|
339
420
|
|
@@ -346,7 +427,7 @@ The Hippius SDK includes a powerful command-line interface (CLI) that provides a
|
|
346
427
|
hippius --help
|
347
428
|
|
348
429
|
# Set global options
|
349
|
-
hippius --gateway https://ipfs.io --api-url https://
|
430
|
+
hippius --gateway https://ipfs.io --api-url https://store.hippius.network --verbose
|
350
431
|
```
|
351
432
|
|
352
433
|
### IPFS Operations
|
@@ -431,7 +512,7 @@ hippius ec-files --all-miners
|
|
431
512
|
hippius ec-files --show-chunks
|
432
513
|
```
|
433
514
|
|
434
|
-
The `ec-files` command
|
515
|
+
The `ec-files` command has been optimized for performance and can now handle large numbers of files efficiently through parallel processing.
|
435
516
|
|
436
517
|
### Using Environment Variables
|
437
518
|
|
@@ -439,7 +520,7 @@ The CLI automatically reads from your `.env` file for common settings:
|
|
439
520
|
|
440
521
|
```
|
441
522
|
IPFS_GATEWAY=https://ipfs.io
|
442
|
-
IPFS_API_URL=https://
|
523
|
+
IPFS_API_URL=https://store.hippius.network
|
443
524
|
SUBSTRATE_URL=wss://rpc.hippius.network
|
444
525
|
SUBSTRATE_SEED_PHRASE="your twelve word seed phrase..."
|
445
526
|
SUBSTRATE_DEFAULT_MINERS=miner1,miner2,miner3
|
@@ -546,13 +627,14 @@ The configuration is organized in the following sections:
|
|
546
627
|
{
|
547
628
|
"ipfs": {
|
548
629
|
"gateway": "https://ipfs.io",
|
549
|
-
"api_url": "https://
|
630
|
+
"api_url": "https://store.hippius.network",
|
550
631
|
"local_ipfs": false
|
551
632
|
},
|
552
633
|
"substrate": {
|
553
634
|
"url": "wss://rpc.hippius.network",
|
554
635
|
"seed_phrase": null,
|
555
|
-
"default_miners": []
|
636
|
+
"default_miners": [],
|
637
|
+
"default_address": null
|
556
638
|
},
|
557
639
|
"encryption": {
|
558
640
|
"encrypt_by_default": false,
|
@@ -737,7 +819,13 @@ hippius --help
|
|
737
819
|
which hippius
|
738
820
|
```
|
739
821
|
|
740
|
-
4. **
|
822
|
+
4. **Default Address Issues**: If you receive errors about missing account address:
|
823
|
+
```bash
|
824
|
+
# Set a default address for read-only operations
|
825
|
+
hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
|
826
|
+
```
|
827
|
+
|
828
|
+
5. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
|
741
829
|
|
742
830
|
## Contributing
|
743
831
|
|
@@ -855,3 +943,95 @@ client = HippiusClient(
|
|
855
943
|
|
856
944
|
The multi-account system makes it easier to manage multiple identities while maintaining security and convenience.
|
857
945
|
|
946
|
+
## Blockchain Account Management
|
947
|
+
|
948
|
+
Hippius SDK provides a comprehensive solution for managing blockchain accounts, including coldkeys, hotkeys, and proxy relationships.
|
949
|
+
|
950
|
+
### Coldkeys and Hotkeys
|
951
|
+
|
952
|
+
Hippius uses a hierarchical account structure:
|
953
|
+
|
954
|
+
- **Coldkey**: The main account that holds your funds and grants permissions
|
955
|
+
- **Hotkey**: Delegated accounts that can perform specific actions on behalf of your coldkey
|
956
|
+
|
957
|
+
This separation provides enhanced security by allowing you to keep your main account (coldkey) secure while using hotkeys for day-to-day operations.
|
958
|
+
|
959
|
+
### Creating and Managing Accounts
|
960
|
+
|
961
|
+
```python
|
962
|
+
from hippius_sdk.account import AccountManager
|
963
|
+
|
964
|
+
# Initialize the account manager
|
965
|
+
account_manager = AccountManager()
|
966
|
+
|
967
|
+
# Create a coldkey (main account)
|
968
|
+
coldkey = account_manager.create_coldkey(
|
969
|
+
name="my_hippius_coldkey", # Optional custom name
|
970
|
+
mnemonic="your mnemonic phrase here" # Optional - will generate if not provided
|
971
|
+
)
|
972
|
+
|
973
|
+
# Create a hotkey associated with the coldkey
|
974
|
+
hotkey = account_manager.create_hotkey(
|
975
|
+
name="my_hippius_hotkey_1", # Optional custom name
|
976
|
+
coldkey_address=coldkey["address"] # Optional association
|
977
|
+
)
|
978
|
+
|
979
|
+
# List all coldkeys
|
980
|
+
coldkeys = account_manager.list_coldkeys()
|
981
|
+
|
982
|
+
# List hotkeys for a specific coldkey
|
983
|
+
hotkeys = account_manager.list_hotkeys(coldkey_address=coldkey["address"])
|
984
|
+
|
985
|
+
# Create a proxy relationship on the blockchain
|
986
|
+
result = account_manager.create_proxy_relationship(
|
987
|
+
coldkey_address=coldkey["address"],
|
988
|
+
hotkey_address=hotkey["address"],
|
989
|
+
proxy_type="NonTransfer", # Type of permissions granted
|
990
|
+
delay=0 # Blocks before proxy becomes active
|
991
|
+
)
|
992
|
+
|
993
|
+
# List proxy relationships
|
994
|
+
proxies = account_manager.list_proxies(coldkey_address=coldkey["address"])
|
995
|
+
|
996
|
+
# Remove a proxy relationship
|
997
|
+
result = account_manager.remove_proxy(
|
998
|
+
coldkey_address=coldkey["address"],
|
999
|
+
hotkey_address=hotkey["address"]
|
1000
|
+
)
|
1001
|
+
```
|
1002
|
+
|
1003
|
+
### CLI Commands for Account Management
|
1004
|
+
|
1005
|
+
The SDK provides CLI commands for managing accounts:
|
1006
|
+
|
1007
|
+
```bash
|
1008
|
+
# Create a coldkey
|
1009
|
+
hippius account coldkey create --name "my_hippius_coldkey" --generate-mnemonic --show-mnemonic
|
1010
|
+
|
1011
|
+
# Create a hotkey and associate with a coldkey
|
1012
|
+
hippius account hotkey create --name "my_hippius_hotkey_1" --coldkey [COLDKEY_ADDRESS]
|
1013
|
+
|
1014
|
+
# List accounts
|
1015
|
+
hippius account list coldkey --verbose
|
1016
|
+
hippius account list hotkey
|
1017
|
+
hippius account list proxy --coldkey [COLDKEY_ADDRESS]
|
1018
|
+
|
1019
|
+
# Create a proxy relationship on the blockchain
|
1020
|
+
hippius account proxy create --coldkey [COLDKEY_ADDRESS] --hotkey [HOTKEY_ADDRESS] --proxy-type NonTransfer
|
1021
|
+
|
1022
|
+
# Remove a proxy relationship
|
1023
|
+
hippius account proxy remove --coldkey [COLDKEY_ADDRESS] --hotkey [HOTKEY_ADDRESS]
|
1024
|
+
```
|
1025
|
+
|
1026
|
+
### Best Practices for Account Management
|
1027
|
+
|
1028
|
+
1. **Security**: Keep your coldkey mnemonic secure and never share it. This is the master key to your account.
|
1029
|
+
|
1030
|
+
2. **Proxy Types**: Different proxy types grant different permissions:
|
1031
|
+
- `NonTransfer`: Can perform operations except transferring funds
|
1032
|
+
- Other types may be available depending on the chain configuration
|
1033
|
+
|
1034
|
+
3. **Multiple Hotkeys**: Create separate hotkeys for different applications or services to limit the impact if one is compromised.
|
1035
|
+
|
1036
|
+
4. **Regular Auditing**: Regularly check your proxy relationships using `hippius account list proxy` to ensure only authorized delegates have access.
|
1037
|
+
|
@@ -36,7 +36,7 @@ client = HippiusClient()
|
|
36
36
|
# Or specify custom endpoints
|
37
37
|
client = HippiusClient(
|
38
38
|
ipfs_gateway="https://ipfs.io", # For downloads (default)
|
39
|
-
ipfs_api_url="https://
|
39
|
+
ipfs_api_url="https://store.hippius.network", # For uploads (default)
|
40
40
|
)
|
41
41
|
|
42
42
|
# Upload a file to IPFS
|
@@ -282,6 +282,64 @@ This command provides detailed information about each erasure-coded file includi
|
|
282
282
|
- Miners storing the file
|
283
283
|
- Reconstruction command
|
284
284
|
|
285
|
+
The `ec-files` command is optimized for performance through parallel processing and intelligent filtering, making it efficient even with large numbers of files.
|
286
|
+
|
287
|
+
#### Performance Considerations
|
288
|
+
|
289
|
+
The erasure coding implementation has been optimized for:
|
290
|
+
|
291
|
+
1. **Speed**: Parallel processing for file operations
|
292
|
+
2. **Memory efficiency**: Files are processed in chunks to minimize memory usage
|
293
|
+
3. **Auto-tuning**: Parameters like chunk size are automatically adjusted for small files
|
294
|
+
4. **Intelligent filtering**: The system can quickly identify potential erasure-coded files
|
295
|
+
|
296
|
+
For extremely large files (>1GB), consider using larger chunk sizes to improve performance:
|
297
|
+
|
298
|
+
```bash
|
299
|
+
hippius erasure-code large_video.mp4 --chunk-size 10485760 # 10MB chunks
|
300
|
+
```
|
301
|
+
|
302
|
+
#### Directory Support for Erasure Coding
|
303
|
+
|
304
|
+
Hippius SDK now supports applying erasure coding to entire directories:
|
305
|
+
|
306
|
+
```bash
|
307
|
+
# Apply erasure coding to an entire directory
|
308
|
+
hippius erasure-code my_directory/
|
309
|
+
|
310
|
+
# The CLI will detect that it's a directory and offer two options:
|
311
|
+
# 1. Archive the directory first, then erasure code the archive
|
312
|
+
# 2. Apply erasure coding to each file in the directory individually
|
313
|
+
```
|
314
|
+
|
315
|
+
When choosing the second option, the system will process each file in the directory individually, adjusting parameters like chunk size automatically for small files. A summary of the operation will be displayed, showing:
|
316
|
+
- Total files processed
|
317
|
+
- Successfully coded files with their metadata CIDs
|
318
|
+
- Any files that failed, with error details
|
319
|
+
|
320
|
+
To reconstruct a file from erasure-coded chunks:
|
321
|
+
|
322
|
+
```bash
|
323
|
+
hippius reconstruct QmMetadataCID reconstructed_filename
|
324
|
+
```
|
325
|
+
|
326
|
+
#### Default Address Management
|
327
|
+
|
328
|
+
Hippius SDK now allows setting a default address for read-only operations, making it easier to use commands like `files` and `ec-files` without specifying an account address each time:
|
329
|
+
|
330
|
+
```bash
|
331
|
+
# Set a default address for read-only operations
|
332
|
+
hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
|
333
|
+
|
334
|
+
# View the currently set default address
|
335
|
+
hippius address get-default
|
336
|
+
|
337
|
+
# Clear the default address
|
338
|
+
hippius address clear-default
|
339
|
+
```
|
340
|
+
|
341
|
+
Once a default address is set, commands like `hippius files` and `hippius ec-files` will automatically use this address when no explicit address is provided.
|
342
|
+
|
285
343
|
#### Troubleshooting
|
286
344
|
|
287
345
|
1. **IPFS Connection Issues**: Make sure you have either:
|
@@ -302,7 +360,30 @@ This command provides detailed information about each erasure-coded file includi
|
|
302
360
|
which hippius
|
303
361
|
```
|
304
362
|
|
305
|
-
4. **
|
363
|
+
4. **Default Address Issues**: If you receive errors about missing account address:
|
364
|
+
```bash
|
365
|
+
# Set a default address for read-only operations
|
366
|
+
hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
|
367
|
+
```
|
368
|
+
|
369
|
+
5. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
|
370
|
+
|
371
|
+
6. **Erasure Coding Problems**:
|
372
|
+
- **"Wrong length for input blocks"**: This typically happens with very small files
|
373
|
+
```bash
|
374
|
+
# Try smaller k and m values for small files
|
375
|
+
hippius erasure-code small_file.txt --k 2 --m 3
|
376
|
+
```
|
377
|
+
- **Directories can't be directly coded**: Use the directory support option when prompted
|
378
|
+
- **"zfec is required"**: Install the missing package
|
379
|
+
```bash
|
380
|
+
pip install zfec
|
381
|
+
poetry add zfec
|
382
|
+
```
|
383
|
+
- **Slow performance with large files**: Increase chunk size
|
384
|
+
```bash
|
385
|
+
hippius erasure-code large_file.mp4 --chunk-size 5242880 # 5MB chunks
|
386
|
+
```
|
306
387
|
|
307
388
|
## Command Line Interface
|
308
389
|
|
@@ -315,7 +396,7 @@ The Hippius SDK includes a powerful command-line interface (CLI) that provides a
|
|
315
396
|
hippius --help
|
316
397
|
|
317
398
|
# Set global options
|
318
|
-
hippius --gateway https://ipfs.io --api-url https://
|
399
|
+
hippius --gateway https://ipfs.io --api-url https://store.hippius.network --verbose
|
319
400
|
```
|
320
401
|
|
321
402
|
### IPFS Operations
|
@@ -400,7 +481,7 @@ hippius ec-files --all-miners
|
|
400
481
|
hippius ec-files --show-chunks
|
401
482
|
```
|
402
483
|
|
403
|
-
The `ec-files` command
|
484
|
+
The `ec-files` command has been optimized for performance and can now handle large numbers of files efficiently through parallel processing.
|
404
485
|
|
405
486
|
### Using Environment Variables
|
406
487
|
|
@@ -408,7 +489,7 @@ The CLI automatically reads from your `.env` file for common settings:
|
|
408
489
|
|
409
490
|
```
|
410
491
|
IPFS_GATEWAY=https://ipfs.io
|
411
|
-
IPFS_API_URL=https://
|
492
|
+
IPFS_API_URL=https://store.hippius.network
|
412
493
|
SUBSTRATE_URL=wss://rpc.hippius.network
|
413
494
|
SUBSTRATE_SEED_PHRASE="your twelve word seed phrase..."
|
414
495
|
SUBSTRATE_DEFAULT_MINERS=miner1,miner2,miner3
|
@@ -515,13 +596,14 @@ The configuration is organized in the following sections:
|
|
515
596
|
{
|
516
597
|
"ipfs": {
|
517
598
|
"gateway": "https://ipfs.io",
|
518
|
-
"api_url": "https://
|
599
|
+
"api_url": "https://store.hippius.network",
|
519
600
|
"local_ipfs": false
|
520
601
|
},
|
521
602
|
"substrate": {
|
522
603
|
"url": "wss://rpc.hippius.network",
|
523
604
|
"seed_phrase": null,
|
524
|
-
"default_miners": []
|
605
|
+
"default_miners": [],
|
606
|
+
"default_address": null
|
525
607
|
},
|
526
608
|
"encryption": {
|
527
609
|
"encrypt_by_default": false,
|
@@ -706,7 +788,13 @@ hippius --help
|
|
706
788
|
which hippius
|
707
789
|
```
|
708
790
|
|
709
|
-
4. **
|
791
|
+
4. **Default Address Issues**: If you receive errors about missing account address:
|
792
|
+
```bash
|
793
|
+
# Set a default address for read-only operations
|
794
|
+
hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
|
795
|
+
```
|
796
|
+
|
797
|
+
5. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
|
710
798
|
|
711
799
|
## Contributing
|
712
800
|
|
@@ -823,3 +911,95 @@ client = HippiusClient(
|
|
823
911
|
```
|
824
912
|
|
825
913
|
The multi-account system makes it easier to manage multiple identities while maintaining security and convenience.
|
914
|
+
|
915
|
+
## Blockchain Account Management
|
916
|
+
|
917
|
+
Hippius SDK provides a comprehensive solution for managing blockchain accounts, including coldkeys, hotkeys, and proxy relationships.
|
918
|
+
|
919
|
+
### Coldkeys and Hotkeys
|
920
|
+
|
921
|
+
Hippius uses a hierarchical account structure:
|
922
|
+
|
923
|
+
- **Coldkey**: The main account that holds your funds and grants permissions
|
924
|
+
- **Hotkey**: Delegated accounts that can perform specific actions on behalf of your coldkey
|
925
|
+
|
926
|
+
This separation provides enhanced security by allowing you to keep your main account (coldkey) secure while using hotkeys for day-to-day operations.
|
927
|
+
|
928
|
+
### Creating and Managing Accounts
|
929
|
+
|
930
|
+
```python
|
931
|
+
from hippius_sdk.account import AccountManager
|
932
|
+
|
933
|
+
# Initialize the account manager
|
934
|
+
account_manager = AccountManager()
|
935
|
+
|
936
|
+
# Create a coldkey (main account)
|
937
|
+
coldkey = account_manager.create_coldkey(
|
938
|
+
name="my_hippius_coldkey", # Optional custom name
|
939
|
+
mnemonic="your mnemonic phrase here" # Optional - will generate if not provided
|
940
|
+
)
|
941
|
+
|
942
|
+
# Create a hotkey associated with the coldkey
|
943
|
+
hotkey = account_manager.create_hotkey(
|
944
|
+
name="my_hippius_hotkey_1", # Optional custom name
|
945
|
+
coldkey_address=coldkey["address"] # Optional association
|
946
|
+
)
|
947
|
+
|
948
|
+
# List all coldkeys
|
949
|
+
coldkeys = account_manager.list_coldkeys()
|
950
|
+
|
951
|
+
# List hotkeys for a specific coldkey
|
952
|
+
hotkeys = account_manager.list_hotkeys(coldkey_address=coldkey["address"])
|
953
|
+
|
954
|
+
# Create a proxy relationship on the blockchain
|
955
|
+
result = account_manager.create_proxy_relationship(
|
956
|
+
coldkey_address=coldkey["address"],
|
957
|
+
hotkey_address=hotkey["address"],
|
958
|
+
proxy_type="NonTransfer", # Type of permissions granted
|
959
|
+
delay=0 # Blocks before proxy becomes active
|
960
|
+
)
|
961
|
+
|
962
|
+
# List proxy relationships
|
963
|
+
proxies = account_manager.list_proxies(coldkey_address=coldkey["address"])
|
964
|
+
|
965
|
+
# Remove a proxy relationship
|
966
|
+
result = account_manager.remove_proxy(
|
967
|
+
coldkey_address=coldkey["address"],
|
968
|
+
hotkey_address=hotkey["address"]
|
969
|
+
)
|
970
|
+
```
|
971
|
+
|
972
|
+
### CLI Commands for Account Management
|
973
|
+
|
974
|
+
The SDK provides CLI commands for managing accounts:
|
975
|
+
|
976
|
+
```bash
|
977
|
+
# Create a coldkey
|
978
|
+
hippius account coldkey create --name "my_hippius_coldkey" --generate-mnemonic --show-mnemonic
|
979
|
+
|
980
|
+
# Create a hotkey and associate with a coldkey
|
981
|
+
hippius account hotkey create --name "my_hippius_hotkey_1" --coldkey [COLDKEY_ADDRESS]
|
982
|
+
|
983
|
+
# List accounts
|
984
|
+
hippius account list coldkey --verbose
|
985
|
+
hippius account list hotkey
|
986
|
+
hippius account list proxy --coldkey [COLDKEY_ADDRESS]
|
987
|
+
|
988
|
+
# Create a proxy relationship on the blockchain
|
989
|
+
hippius account proxy create --coldkey [COLDKEY_ADDRESS] --hotkey [HOTKEY_ADDRESS] --proxy-type NonTransfer
|
990
|
+
|
991
|
+
# Remove a proxy relationship
|
992
|
+
hippius account proxy remove --coldkey [COLDKEY_ADDRESS] --hotkey [HOTKEY_ADDRESS]
|
993
|
+
```
|
994
|
+
|
995
|
+
### Best Practices for Account Management
|
996
|
+
|
997
|
+
1. **Security**: Keep your coldkey mnemonic secure and never share it. This is the master key to your account.
|
998
|
+
|
999
|
+
2. **Proxy Types**: Different proxy types grant different permissions:
|
1000
|
+
- `NonTransfer`: Can perform operations except transferring funds
|
1001
|
+
- Other types may be available depending on the chain configuration
|
1002
|
+
|
1003
|
+
3. **Multiple Hotkeys**: Create separate hotkeys for different applications or services to limit the impact if one is compromised.
|
1004
|
+
|
1005
|
+
4. **Regular Auditing**: Regularly check your proxy relationships using `hippius account list proxy` to ensure only authorized delegates have access.
|
@@ -4,6 +4,8 @@ Hippius SDK - Python interface for Hippius blockchain storage
|
|
4
4
|
|
5
5
|
from hippius_sdk.client import HippiusClient
|
6
6
|
from hippius_sdk.ipfs import IPFSClient
|
7
|
+
from hippius_sdk.substrate import SubstrateClient
|
8
|
+
from hippius_sdk.account import AccountManager
|
7
9
|
from hippius_sdk.config import (
|
8
10
|
get_config_value,
|
9
11
|
set_config_value,
|
@@ -29,6 +31,8 @@ __version__ = "0.1.0"
|
|
29
31
|
__all__ = [
|
30
32
|
"HippiusClient",
|
31
33
|
"IPFSClient",
|
34
|
+
"SubstrateClient",
|
35
|
+
"AccountManager",
|
32
36
|
"get_config_value",
|
33
37
|
"set_config_value",
|
34
38
|
"get_encryption_key",
|