Skip to main content

Python SDK for Conflux network

Project description

Introduction

Binder Documentation Status gitlocalized codecov

README | 中文文档

Overview

Python-conflux-sdk helps to interact with Conflux network using python. It is built over web3.py and most of its APIs are consistent with web3.py.

Quickstart

Requirements: python version >= 3.7

$ 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
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:

# modified from https://web3py.readthedocs.io/en/stable/middleware.html#signing
from conflux_web3 import Web3
w3 = Web3("https://test.confluxrpc.com")
from conflux_web3.middleware import construct_sign_and_send_raw_middleware
from cfx_account import Account
acct = Account.create('KEYSMASH FJAFJKLDSKF7JKFDJ 1530')
w3.middleware_onion.add(construct_sign_and_send_raw_middleware(acct))
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.

Localization

Currently this documentation supports:

  • English version
  • Chinese version

And welcome to provide translation in GitLocalize.

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

conflux-web3-1.0.0.tar.gz (58.0 kB view details)

Uploaded Source

Built Distribution

conflux_web3-1.0.0-py3-none-any.whl (75.5 kB view details)

Uploaded Python 3

File details

Details for the file conflux-web3-1.0.0.tar.gz.

File metadata

  • Download URL: conflux-web3-1.0.0.tar.gz
  • Upload date:
  • Size: 58.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for conflux-web3-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8252e207e014528a776136874ebdb6609497be36e9e89b065e3a5fc279ab8a03
MD5 37fabf2c68ce8c60a338466f4df14711
BLAKE2b-256 fbd7f1211d4dfb8fd3732335ed7727d96060501d0e19cbf043eed4fa4ae87b51

See more details on using hashes here.

File details

Details for the file conflux_web3-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: conflux_web3-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 75.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for conflux_web3-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33c6b671b2116f6d4d5fc2efcc19cd1f9eb76b79c637cc50b2dd0500b7a72e9d
MD5 bf3eb6c6da06162a92e5b6ad5ebdd7b4
BLAKE2b-256 8b1148d687a3d2e27abb67f03b7e34bac821214e1361c8fed9369ba0f12dc974

See more details on using hashes here.

Supported by

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