Python SDK for Conflux network
Project description
Introduction
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
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
conflux-web3-1.0.0b8.tar.gz
(57.8 kB
view hashes)
Built Distribution
Close
Hashes for conflux_web3-1.0.0b8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c76afd8d767aa712a1287abb928a15468bba7c79e9ac2cbae7566ac8c6d6dbf |
|
MD5 | e81f91b7a840b04a630323b5c20b4f0a |
|
BLAKE2b-256 | 2b377bfd3866e9c864de7241adbbf59398ef34d21a81122a6d82797c645f8f0a |