Introduction
Overview
Python-conflux-sdk (or conflux-web3) helps to interact with Conflux network using python. It is built over web3.py and most of its APIs are consistent with web3.py.
Note: python-conflux-sdk v1.3.0 is the version compatible with web3.py v6.x. If you are using web3.py v7.x, please use the v1.4.0 or later.
Quickstart
Requirements: python version >= 3.8
$ pip3 install conflux-web3
from conflux_web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://test.confluxrpc.com"))
acct = w3.account.from_key("0xxxxxxxxxxxxxx")
w3.cfx.default_account = acct
# Uncomment the following line if there is not CFX in your account
# w3.cfx.contract(name="Faucet").claimCfx().transact().executed()
w3.cfx.send_transaction({
'to': w3.address.zero_address(),
'value': 10**18,
}).executed()
Or you can also use API as you do in web3.py before v6.20:
# modified from https://web3py.readthedocs.io/en/v6.20.2/transactions.html#chapter-1-w3-eth-send-transaction-signer-middleware
from conflux_web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://test.confluxrpc.com"))
from conflux_web3.middleware import SignAndSendRawMiddlewareBuilder
from cfx_account import Account
acct = Account.create('KEYSMASH FJAFJKLDSKF7JKFDJ 1530', network_id=w3.cfx.chain_id)
w3.middleware_onion.inject(SignAndSendRawMiddlewareBuilder.build(acct), layer=0)
w3.cfx.default_account = acct.address
transaction = {
'to': w3.address.zero_address(),
'value': 22,
}
w3.cfx.send_transaction(transaction)
Documentations
More detailed code examples are provided in the documentation.
Run Code Examples Online!
All code examples can be run online in mybinder. You can click 🚀 -> Binder on the top bar to activate the running environment. All dependencies wil be installed and the example can be run immediately.
Metadata
Release files for conflux-web3 1.4.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| conflux_web3-1.4.4.tar.gz | 63.1 kB | Without provenance | Details for conflux_web3-1.4.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| conflux_web3-1.4.4-py3-none-any.whl | Python 3 | none | any | Details for conflux_web3-1.4.4-py3-none-any.whl |
Total release size: 142.1 kB
Release files / conflux_web3-1.4.4.tar.gz
| Download URL | conflux_web3-1.4.4.tar.gz |
|---|---|
| Size | 63.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9fb57b3c157d8e0f822081dcdb44d789b3486efe3e7efa695fef89749665413
|
|
BLAKE2b-256 checksum How to use checksums |
127746b8a3d3d4108938e34356d3c34930a31d95fb34c308c357c58f3d27777a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / conflux_web3-1.4.4-py3-none-any.whl
| Download URL | conflux_web3-1.4.4-py3-none-any.whl |
|---|---|
| Size | 78.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
326b61e4ac4f98fe96967106e77688b79916b9f0a57fdf32fdd94cb251a657c5
|
|
BLAKE2b-256 checksum How to use checksums |
259887d2ec943cf4eb226d201cdc306ba76984bdd8f0aa720e6e60b8ad948eb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for conflux-web3 1.4.4
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.