peaq python sdk
Project description
Peaq SDK (Python)
A robust Python SDK for seamless interaction with the peaq blockchain, supporting both EVM and Substrate-based operations. It provides tools to manage Decentralized Identifiers (DIDs), interact with on-chain storage, and perform blockchain transactions with or without local signing capabilities.
Features
- DID creation and management
- On-chain storage utilization
- RBAC capabilities (coming soon)
- Universal Machine Time (coming soon)
Installation
Install via pip:
pip install peaq-sdk
Quick Start
Initialize the SDK for interaction:
EVM Connection
from peaq_sdk import Sdk
from peaq_sdk.types import ChainType
# Without signing capabilities (read-only and transaction creation)
sdk = Sdk.create_instance(
base_url="https://peaq.api.onfinality.io/public",
chain_type=ChainType.EVM,
)
# With signing capabilities
sdk = Sdk.create_instance(
base_url="https://peaq.api.onfinality.io/public",
chain_type=ChainType.EVM,
seed=my_private_key_or_mnemonic,
)
Substrate Connection
from peaq_sdk import Sdk
from peaq_sdk.types import ChainType
# Without signing capabilities (read-only and transaction creation)
sdk = Sdk.create_instance(
base_url="wss://peaq.api.onfinality.io/public-ws",
chain_type=ChainType.Substrate,
)
# With signing capabilities
sdk = Sdk.create_instance(
base_url="wss://peaq.api.onfinality.io/public-ws",
chain_type=ChainType.Substrate,
seed=my_private_key_or_mnemonic,
)
Decentralized Identifiers (DID)
Create a DID
from peaq_sdk.types import CustomDocumentFields, Verification
custom_fields = CustomDocumentFields(
verifications=[Verification(type='EcdsaSecp256k1RecoveryMethod2020')]
)
result = sdk.did.create(name="myDid", custom_document_fields=custom_fields)
Read a DID
result = sdk.did.read(name="myDid")
Update a DID
from peaq_sdk.types import CustomDocumentFields, Verification
custom_fields = CustomDocumentFields(
verifications=[Verification(type='EcdsaSecp256k1RecoveryMethod2020')]
)
result = sdk.did.update(name="myDid", custom_document_fields=custom_fields)
Delete a DID
result = sdk.did.delete(name="myDid")
On-chain Storage
Add Item
result = sdk.storage.add_item(item_type='key', item='value')
Read Item
result = sdk.storage.get_item(item_type='key')
Update Item
sdk.storage.update_item(item_type='key', item='new_value')
Remove Item
sdk.storage.remove_item(item_type='key')
For a more detailed explanation of the functionality please checkout our Python Sdk Reference.
Security and Private Keys
- Private keys are never stored, sent, or logged by the SDK.
- Signing occurs locally only.
- Private keys are used solely to generate an Account or Keypair, after which they are discarded from memory.
- Ensure your local environment securely manages and protects private keys. Never share your private keys.
Development
Virtual Environment
python3 -m venv working_env
source working_env/bin/activate
Build Package
pip install -r requirements.txt
python -m build
Exit Virtual Environment
deactivate
Testing
Checkout the README.md file in /tests directory for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file peaq_sdk-0.0.4.tar.gz.
File metadata
- Download URL: peaq_sdk-0.0.4.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e757cb371139746e451e1b51300ec64a0d8abf39a63abeb9d536295d76bb357
|
|
| MD5 |
cd8966a988386076ee1ea11681411119
|
|
| BLAKE2b-256 |
7ef2a75c205dfdfd91a26801a51a125d335b7d6ed0b3ec0919388afc14d15955
|
Provenance
The following attestation bundles were made for peaq_sdk-0.0.4.tar.gz:
Publisher:
publish.yml on peaqnetwork/peaq-sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
peaq_sdk-0.0.4.tar.gz -
Subject digest:
7e757cb371139746e451e1b51300ec64a0d8abf39a63abeb9d536295d76bb357 - Sigstore transparency entry: 194063375
- Sigstore integration time:
-
Permalink:
peaqnetwork/peaq-sdk-py@beae14c1332084febd0fa5f62e5a6b0b3d3caa7f -
Branch / Tag:
refs/heads/dev - Owner: https://github.com/peaqnetwork
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@beae14c1332084febd0fa5f62e5a6b0b3d3caa7f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file peaq_sdk-0.0.4-py3-none-any.whl.
File metadata
- Download URL: peaq_sdk-0.0.4-py3-none-any.whl
- Upload date:
- Size: 25.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af7e6238803dd7e19c330c9bd6eb58605b02dc451e1095dd2a34a1167c92edb7
|
|
| MD5 |
2cb2c0b5e2f53260eaba9a0757ecfab9
|
|
| BLAKE2b-256 |
be6bcdcce11583eafd7385bb1b4c7419186fc62bd91080a393c25e9a521e672a
|
Provenance
The following attestation bundles were made for peaq_sdk-0.0.4-py3-none-any.whl:
Publisher:
publish.yml on peaqnetwork/peaq-sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
peaq_sdk-0.0.4-py3-none-any.whl -
Subject digest:
af7e6238803dd7e19c330c9bd6eb58605b02dc451e1095dd2a34a1167c92edb7 - Sigstore transparency entry: 194063381
- Sigstore integration time:
-
Permalink:
peaqnetwork/peaq-sdk-py@beae14c1332084febd0fa5f62e5a6b0b3d3caa7f -
Branch / Tag:
refs/heads/dev - Owner: https://github.com/peaqnetwork
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@beae14c1332084febd0fa5f62e5a6b0b3d3caa7f -
Trigger Event:
workflow_dispatch
-
Statement type: