Skip to main content

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==0.1.1

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:

  1. Fork the repository.
  2. Create a new branch for your changes.
  3. Make your changes and write tests.
  4. 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:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solidity_python_sdk-0.1.5.tar.gz (31.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solidity_python_sdk-0.1.5-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

Details for the file solidity_python_sdk-0.1.5.tar.gz.

File metadata

  • Download URL: solidity_python_sdk-0.1.5.tar.gz
  • Upload date:
  • Size: 31.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for solidity_python_sdk-0.1.5.tar.gz
Algorithm Hash digest
SHA256 5c83a75269af9ec7888233d95f195b8ad1f143ef6a275c2a224cbc535868539e
MD5 26a8ce3d68a38e0cd2d48e1eda0fffb1
BLAKE2b-256 c53518f4b3d95043fa180443fa3f8a400bcfa00ba1fb73e15ad437131654ebf6

See more details on using hashes here.

File details

Details for the file solidity_python_sdk-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for solidity_python_sdk-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f33337726e842d5824c1c3501c1a2d3312dcd6ea0a6780610bd71e106a9b9270
MD5 5cbc098fad9dedbaa68b827a30e3531d
BLAKE2b-256 d348e837a0e09b4861ef9d7608ba3b3e5b71fedf7de697fb3542531933bc5719

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page