Official Circular Protocol Enterprise APIs written in Python.
Project description
Circular Enterprise Python APIs for Data Certification
This library provides Python implementations of the Circular Enterprise APIs for data certification and blockchain integration. It includes classes and helper functions to interact with the Circular network, submit certificates, retrieve transactions, and manage accounts.
Features:
- Data Certification: Submit data to the blockchain for certification.
- Transaction Retrieval: Fetch transaction details by ID or block range.
- Account Management: Open, update, and close accounts.
- Secure Signing: Sign data using elliptic curve cryptography (secp256k1).
- Network Integration: Connect to different blockchain networks (mainnet, testnet, devnet). """
Installation Instructions:
Installation
You can install this library using pip:
pip install circular_enterprise_apis
Usage Instructions:
Usage
- Opening an Account:
from circular_enterprise_apis import CEP_Account
account = CEP_Account()
account.open('a4fc8b11bfc5dc2911ab41871e6de81f500fe60f3961343b202ad78e7e297ea08')
print("Account opened successfully.")
- Choosing a network and the blockchain:
blockchain = 'blockchain-address'
account.set_network("testnet") # chose between multiple networks such as testnet, devnet and mainnet
account.set_blockchain(blockchain)
- Retrieve account informations
if account.update_account():
#...
- Submitting a Certificate:
pdata = 'Your data to certify'
private_key = 'your_private_key_here'
try:
response = account.submit_certificate(pdata, private_key)
print(response)
except Exception as e:
print(f"Error: {e}")
- Retrieving a Transaction:
#...
resp = account.get_transaction_by_id(tx_id, 0, 10)
if resp["Response"]["BlockID"]:
block_id = resp["Response"]["BlockID"]
status = account.get_transaction(block_id, tx_id)
if status["Result"] == 200:
print(f"Transaction Status: {status['Response']['Status']}")
account.close()
else:
print("Error on retrieving transaction")
else:
print("Error on retrieving transaction status")
#...
Example Workflow:
from circular_enterprise_apis import CEP_Account
try:
# Instantiate the CEP Account class
account = CEP_Account()
print("CEP_Account instantiated successfully.")
address = "your-account-address"
private_key = "your-private-key"
blockchain = "blockchain-address"
tx_id = ""
tx_block = ""
account.set_network("testnet")
account.set_blockchain(blockchain)
print("Test variables set.")
if account.open(address):
print("Account opened successfully.")
if account.update_account():
print(f"Nonce: {account.Nonce}")
tx_id_temp = account.submit_certificate(
"your-data-to-certificate",
private_key
)
if tx_id_temp["Result"] == 200:
tx_id = tx_id_temp["Response"]["TxID"]
print(f"TxID: {tx_id}")
resp = account.get_transaction_by_id(tx_id, 0, 10)
if resp["Response"]["BlockID"]:
block_id = resp["Response"]["BlockID"]
status = account.get_transaction(block_id, tx_id)
if status["Result"] == 200:
print(f"Transaction Status: {status['Response']['Status']}")
account.close()
else:
print("Error on retrieving transaction")
else:
print("Error on retrieving transaction status")
else:
print("Certificate submission error")
else:
print(f"Update Account Error: {account.lastError}")
else:
print(f"Failed to open account: {account.lastError}")
except Exception as e:
print(f"An error occurred: {e}")
Helper Functions:
Helper Functions:
- hex_fix(hex): Removes '0x' from hexadecimal strings.
- string_to_hex(string): Converts a string to its hexadecimal representation.
- hex_to_string(hex): Converts a hexadecimal string back to a regular string.
- get_formatted_timestamp(): Returns the current timestamp in YYYY:MM:DD-HH:MM:SS format.
Contributing:
Contributing: Contributions are welcome! If you'd like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request with a detailed description of your changes.
License:
License: This project is licensed under the MIT License. See the LICENSE file for details.
Support:
Support: For questions or issues, please open an issue on the GitHub repository.
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 circular_enterprise_apis-1.0.1.tar.gz.
File metadata
- Download URL: circular_enterprise_apis-1.0.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7c482067d0a4d843a6d539a42618334cca8e55260c7b54e4ddcf03c67194595
|
|
| MD5 |
27db1de4ca9f3dd266e97bf8f8694820
|
|
| BLAKE2b-256 |
16c91b08b46d25e5679c684654687c886779be51e23c62ad7a4b381b2c1887bf
|
Provenance
The following attestation bundles were made for circular_enterprise_apis-1.0.1.tar.gz:
Publisher:
python-publish.yml on circular-protocol/Python-Enterprise-APIs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
circular_enterprise_apis-1.0.1.tar.gz -
Subject digest:
d7c482067d0a4d843a6d539a42618334cca8e55260c7b54e4ddcf03c67194595 - Sigstore transparency entry: 231872018
- Sigstore integration time:
-
Permalink:
circular-protocol/Python-Enterprise-APIs@75273134b11ed608e4fa6944eacc47487571d7fb -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/circular-protocol
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@75273134b11ed608e4fa6944eacc47487571d7fb -
Trigger Event:
release
-
Statement type:
File details
Details for the file circular_enterprise_apis-1.0.1-py3-none-any.whl.
File metadata
- Download URL: circular_enterprise_apis-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.7 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 |
976a23807d0298095bfad5c0c2f15d381c7e4c59930f35b214ad2356c3e9aa3a
|
|
| MD5 |
3bd9269e133a14cae12cfc980752724c
|
|
| BLAKE2b-256 |
00953cae74f130096f7822ffbb28461299644a7ea4f331db9357a7b493ca7eaf
|
Provenance
The following attestation bundles were made for circular_enterprise_apis-1.0.1-py3-none-any.whl:
Publisher:
python-publish.yml on circular-protocol/Python-Enterprise-APIs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
circular_enterprise_apis-1.0.1-py3-none-any.whl -
Subject digest:
976a23807d0298095bfad5c0c2f15d381c7e4c59930f35b214ad2356c3e9aa3a - Sigstore transparency entry: 231872023
- Sigstore integration time:
-
Permalink:
circular-protocol/Python-Enterprise-APIs@75273134b11ed608e4fa6944eacc47487571d7fb -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/circular-protocol
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@75273134b11ed608e4fa6944eacc47487571d7fb -
Trigger Event:
release
-
Statement type: