Skip to main content

pyc3l

Latest Pypi Version

This project allow to create python scripts communicating with the ComChain API.

Maturity

This code is in alpha stage. It wasn't tested on Windows. API may change. This is more a draft for an ongoing reflection.

Requirement

This code is for python3 and uses:

  • eth_account
  • web3
  • ecdsa
  • requests

It is tested on Python 3.9, 3.10, 3.11 and 3.12.

Installation

You don't need to download the git version of the code as pyc3l is available on the PyPI. So you should be able to run:

pip install pyc3l

If you have downloaded the GIT sources, then you could add install the current version via traditional::

pip install .

And if you don't have the GIT sources but would like to get the latest master or branch from github, you could also::

pip install git+https://github.com/com-chain/pyc3l

Or even select a specific revision (branch/tag/commit)::

pip install git+https://github.com/com-chain/pyc3l@master

Usage

from pyc3l import Pyc3l

## Instantiate our interface to Comchain's node
#pyc3l = Pyc3l()
pyc3l = Pyc3l(block_number="pending")  ## default

## load your ciphered wallet
wallet = pyc3l.Wallet.from_json(json_string_wallet)

## use the ``wallet`` object to read the blockchain

wallet.isValidAdmin
wallet.status

wallet.globalBalance
wallet.nantBalance
wallet.cmBalance
wallet.cmLimitMin
wallet.cmLimitMax

wallet.Allowances        ## dict of {address: amount}
wallet.Requests          ## dict of {address: amount}
wallet.MyRequests        ## dict of {address: amount}
wallet.Delegations       ## dict of {address: amount}
wallet.MyDelegations     ## dict of {address: amount}
wallet.AcceptedRequests  ## dict of {address: amount}
wallet.RejectedRequests  ## dict of {address: amount}


## use the ``wallet`` object to emit transaction

## unlock your wallet with your password
wallet.unlock(mypassword)

wallet.enable(address)
wallet.disable(address)

wallet.pledge(address, amount, amount,  message_from="", message_to="")
wallet.delegate(address, amount)

wallet.transferNant(address, amount, message_from="", message_to="")
wallet.transferOnBehalfOf(address_from, address_to, amount, message_from="", message_to="")


## Get the currency object

currency = Currency("Lemanopolis")
## or from wallet:
currency = wallet.currency

currency.getAmountPledged()  ## total pledged amount


## get account in a currency

account = currency.Account("0x...")

account.nonce_hex
account.nonce_dec
account.eth_balance
account.eth_balance_gwei
account.eth_balance_eth

account.active
account.owner
account.role

account.allowances         ## dict of {address: amount}
account.requests           ## dict of {address: amount}
account.my_requests        ## dict of {address: amount}
account.delegations        ## dict of {address: amount}
account.my_delegations     ## dict of {address: amount}
account.accepted_requests  ## dict of {address: amount}
account.rejected_requests  ## dict of {address: amount}

Please note that pyc3l-cli package has a lot of short and simple scripts to showcase the usage of the library.

Contributing

Any suggestions or issues are welcome. Push requests are very welcome, please check out the guidelines.

Test

To run the tests, you'll need to install hatch and::

hatch run test

Push Request Guidelines

You can send any code. I'll look at it and will integrate it myself in the code base and leave you as the author. This process can take time and it'll take less time if you follow the following guidelines:

  • check your code with PEP8 or pylint. Try to stick to 80 columns wide.
  • separate your commits per smallest concern.
  • each commit should pass the tests (to allow easy bisect)
  • each functionality/bugfix commit should contain the code, tests, and doc.
  • prior minor commit with typographic or code cosmetic changes are very welcome. These should be tagged in their commit summary with !minor.
  • the commit message should follow gitchangelog rules (check the git log to get examples)
  • if the commit fixes an issue or finished the implementation of a feature, please mention it in the summary.

If you have some questions about guidelines which is not answered here, please check the current git log, you might find previous commit that shows you how to deal with your issue.

License

Licensed under the [GNU Affero General Public License](GNU Affero General Public License: http://raw.github.com/com-chain/pyc3l/master/LICENSE)

Metadata

Release files for pyc3l 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyc3l 0.6.1
File Size Uploaded Provenance Actions
pyc3l-0.6.1.tar.gz 35.8 kB Without provenance Details for pyc3l-0.6.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyc3l 0.6.1
File Interpreter ABI Platform Actions
pyc3l-0.6.1-py3-none-any.whl Python 3 none any Details for pyc3l-0.6.1-py3-none-any.whl

Total release size: 73.4 kB

Release files / pyc3l-0.6.1.tar.gz

Download URL pyc3l-0.6.1.tar.gz
Size 35.8 kB
Tags Source
SHA-256 checksum
How to use checksums
32211b486c7ca84cd1d5d0c0d8aef91d5b31346296115e888b277e21f04539cd
BLAKE2b-256 checksum
How to use checksums
c76f1c09ea3bff610dce5bb1f102e2ee2ff09a74848aa351e286d200db1e5dab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / pyc3l-0.6.1-py3-none-any.whl

Download URL pyc3l-0.6.1-py3-none-any.whl
Size 37.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4649c33eecf42499b287c252bb3c71d53c53d1b86e38ed26b386695f01f1b15
BLAKE2b-256 checksum
How to use checksums
c1dafef49c82d26da3afdec8eaab3431bee3289e966a14444595e17dee045575
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Security for pyc3l 0.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page