SDK for interacting with Digital Product Passport smart contracts
Project description
Solidity Python SDK
Overview
The Solidity Python SDK is a Python library designed for interacting with Digital Product Passport smart contracts. It provides an easy-to-use interface for deploying and interacting with smart contracts on the Ethereum blockchain.
Features
- Load Contracts: Load and interact with pre-deployed smart contracts.
- Deploy Contracts: Deploy new smart contracts to the Ethereum blockchain.
- Set and Get Product Details: Set and retrieve detailed product information from smart contracts.
- Authorize Entities: Authorize entities for specific roles in the smart contract.
- Support for IPFS: Integrate with IPFS for storing and retrieving product-related documents.
Installation
To install the SDK, you can use pip:
pip install -i https://test.pypi.org/simple/ solidity-python-sdk
or
pip install solidity-python-sdk
Usage
Here's a quick start guide to help you get started with the SDK:
Basic Usage
from solidity_python_sdk.main import DigitalProductPassportSDK
sdk = DigitalProductPassportSDK()
Deploy a Contract
from solidity_python_sdk.main import ProductPassport
account_address = "0xYourEthereumAddress"
passport = ProductPassport(sdk)
contract_address = passport.deploy(account_address)
print(f"Contract deployed at address: {contract_address}")
Authorize an Entity
entity_address = "0xEntityAddress"
role = "manufacturer"
tx_receipt = passport.authorize_entity(contract_address, entity_address, role)
print(f"Entity authorized. Transaction receipt: {tx_receipt}")
Set Product Details
product_details = {
"uid": "UID123",
"gtin": "GTIN123",
"taricCode": "TARIC123",
"manufacturerInfo": "Manufacturer info",
"consumerInfo": "Consumer info",
"endOfLifeInfo": "End of life info"
}
tx_receipt = passport.set_product(contract_address, "123456", product_details)
print(f"Transaction receipt: {tx_receipt}")
Get Product Details
product_data_retrieved = passport.get_product(contract_address, "123456")
print(f"Retrieved product data: {product_data_retrieved}")
Set Product Data
product_data = {
"description": "Product description",
"manuals": ["QmWDYhFAaT89spcqbKYboyCm6mkYSxKJaWUuS18Akmw96t"],
"specifications": ["QmWDYhFAaT89spcqbKYboyCm6mkYSxKJaWUuS18Akmw96t"],
"batchNumber": "Batch123",
"productionDate": "2024-07-19",
"expiryDate": "2025-07-19",
"certifications": "Certifications info",
"warrantyInfo": "Warranty info",
"materialComposition": "Material info",
"complianceInfo": "Compliance info"
}
tx_receipt = passport.set_product_data(contract_address, 123456, product_data)
print(f"Transaction receipt: {tx_receipt}")
Get Product Data
product_data_retrieved = passport.get_product_data(contract_address, 123456)
print(f"Retrieved product data: {product_data_retrieved}")
Documentation
The documentation for the SDK is available in the docs directory. You can view the documentation in Markdown format or convert it to other formats if needed.
Contributing
We welcome contributions to improve the SDK! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch for your changes.
- Make your changes and write tests.
- Submit a pull request with a clear description of your changes.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact
For any questions or support, please contact:
- Author: Luthiano Trarbach
- Email: luthiano.trarbach@proton.me
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 solidity_python_sdk-0.1.19.tar.gz.
File metadata
- Download URL: solidity_python_sdk-0.1.19.tar.gz
- Upload date:
- Size: 33.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cccdc21ae884d91efd500e8cc4a61adaf650304370e62a2595f099e8e4cb0684
|
|
| MD5 |
ad78f4fdf904b9b2e1050a8d4328d856
|
|
| BLAKE2b-256 |
52bf04bf2604cde64d445cbe4ebd12f5c6ba84660d758b13f166ac1446993c77
|
File details
Details for the file solidity_python_sdk-0.1.19-py3-none-any.whl.
File metadata
- Download URL: solidity_python_sdk-0.1.19-py3-none-any.whl
- Upload date:
- Size: 38.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aae87d44a4955534426ae51e5339b338179e78adb7260b594d2fc2487b71292d
|
|
| MD5 |
87fecf518a333bdd688e1b14db6605fe
|
|
| BLAKE2b-256 |
e89bf69ce744d2f190fc5b5a1c2caaf8e1ea4e83feb0a76303bcbb00586c4b76
|