Metadata-Version: 2.1
Name: conflux-web3
Version: 1.4.0
Summary: Python SDK for Conflux network
Home-page: https://github.com/conflux-chain/python-conflux-sdk
Author: Conflux-Dev
Author-email: wenda.zhang@confluxnetwork.org
Keywords: python,conflux,blockchain
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Description-Content-Type: text/markdown
Requires-Dist: web3==7.8.0
Requires-Dist: cfx-address>=1.2.0
Requires-Dist: cfx-account>=1.2.0
Requires-Dist: cfx-utils>=1.0.5
Provides-Extra: tester
Requires-Dist: docker<8,>=7.1.0; extra == "tester"
Requires-Dist: pytest<9,>=8; extra == "tester"
Requires-Dist: pytest-xdist<4,>=3; extra == "tester"
Requires-Dist: typing_extensions; extra == "tester"
Requires-Dist: pytest-cov; extra == "tester"
Requires-Dist: ipfshttpclient==0.8.0a2; extra == "tester"
Requires-Dist: python-dotenv; extra == "tester"
Requires-Dist: setuptools; extra == "tester"
Requires-Dist: pydantic<3,>=2.6.0; extra == "tester"
Requires-Dist: cfx-address>=1.2.0; extra == "tester"
Requires-Dist: pytest-xdist; extra == "tester"
Requires-Dist: pytest-order; extra == "tester"
Provides-Extra: linter
Requires-Dist: black<23.0,>=22.1.0; extra == "linter"
Provides-Extra: docs
Requires-Dist: jupyter-book; extra == "docs"
Requires-Dist: mmg==2.0.0; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
Requires-Dist: wheel; extra == "docs"
Provides-Extra: dev
Requires-Dist: docker<8,>=7.1.0; extra == "dev"
Requires-Dist: pytest<9,>=8; extra == "dev"
Requires-Dist: pytest-xdist<4,>=3; extra == "dev"
Requires-Dist: typing_extensions; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ipfshttpclient==0.8.0a2; extra == "dev"
Requires-Dist: python-dotenv; extra == "dev"
Requires-Dist: setuptools; extra == "dev"
Requires-Dist: pydantic<3,>=2.6.0; extra == "dev"
Requires-Dist: cfx-address>=1.2.0; extra == "dev"
Requires-Dist: pytest-xdist; extra == "dev"
Requires-Dist: pytest-order; extra == "dev"
Requires-Dist: black<23.0,>=22.1.0; extra == "dev"
Requires-Dist: jupyter-book; extra == "dev"
Requires-Dist: mmg==2.0.0; extra == "dev"
Requires-Dist: sphinx-autodoc-typehints; extra == "dev"
Requires-Dist: wheel; extra == "dev"
Requires-Dist: bumpversion; extra == "dev"
Requires-Dist: twine; extra == "dev"
Provides-Extra: ipfs
Requires-Dist: ipfshttpclient==0.8.0a2; extra == "ipfs"

# Introduction

[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/conflux-chain/python-conflux-sdk/dev?urlpath=tree/docs/en/examples/01-quickstart.ipynb)
[![Documentation Status](https://readthedocs.org/projects/python-conflux-sdk/badge/?version=latest)](https://python-conflux-sdk.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/github/Conflux-Chain/python-conflux-sdk/branch/dev/graph/badge.svg?token=GZ62V9QW0A)](https://codecov.io/github/Conflux-Chain/python-conflux-sdk)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/conflux-web3)

[README](https://python-conflux-sdk.readthedocs.io/en/latest/README.html) | [中文文档](https://python-conflux-sdk.readthedocs.io/zh_CN/latest/README.html)

- [Introduction](#introduction)
  - [Overview](#overview)
  - [Quickstart](#quickstart)
  - [Documentations](#documentations)
    - [Run Code Examples Online!](#run-code-examples-online)


## Overview

Python-conflux-sdk (or conflux-web3) helps to interact with Conflux network using python. It is built over [web3.py](https://github.com/ethereum/web3.py) and most of its APIs are consistent with [web3.py](https://github.com/ethereum/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

```bash
$ pip3 install conflux-web3
```

```python
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:

``` python
# 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](https://python-conflux-sdk.readthedocs.io/en/latest/README.html).

### Run Code Examples Online!

All code examples can be run online in [mybinder](https://mybinder.org/). 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.
