Skip to main content

Plugin to monkey patch web3.py to support cfx2eth-bridge

Project description

Introduction

This is a library used to use web3.py on conflux-bridge(?). This library hacks the signing machanism of web3.py.

Install

This library requires python >= 3.7

It is recommended to use this library in a virtual environment.

python -m venv venv
source ./venv/bin/activate

or

conda create -n venv python=3.7
conda activate venv

Then install in the virtual environment

pip install conflux-web3py-signer

How to use

Basic Usage

Import conflux_we3py_signer before import web3.

import conflux_web3py_signer
import web3

Use with Brownie

Firstly, you are supposed to install brownie and add conflux-bridge endpoints to brownie networks

pip install conflux_web3py_signer[brownie]
cfx-brownie networks add Conflux cfx-testnet-bridge host=https://cfx2ethtest.nftrainbow.cn chainid=1

Then use with command-line with target network.

cfx-brownie --network cfx-testnet-bridge

What is Done

Transaction Cast

When the modified construct_sign_and_send_raw_middleware is going to sign a transaction, it will convert an EIP-1559 transaction to conflux transaction following the rule:

  • If gasPrice is missing, use maxFeePerGas as gas price.
  • Fill epochHeight with w3.eth.block_number, which correspondes to epoch_number in conflux.
  • Estimate the transaction and fill storageLimit from estimate result.

Address Cast

EOA account addresses are all converted to begin with 0x1 and is encoded in checksum format

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-web3py-signer-1.0.0b3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

conflux_web3py_signer-1.0.0b3-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file conflux-web3py-signer-1.0.0b3.tar.gz.

File metadata

File hashes

Hashes for conflux-web3py-signer-1.0.0b3.tar.gz
Algorithm Hash digest
SHA256 b62587c46222e53d2ea394953214ebfb618d653fc27f1c011c762aab30e29dcb
MD5 b98b70ba28afc55e4bd8905eb4472052
BLAKE2b-256 19be903c226809c6863318432967e72b2b53f227d30456744b60a4a5d438565f

See more details on using hashes here.

Provenance

File details

Details for the file conflux_web3py_signer-1.0.0b3-py3-none-any.whl.

File metadata

File hashes

Hashes for conflux_web3py_signer-1.0.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 8da0a3b96eade2e9425f9435ed4618f482f4e6b4fb14384212a7e0e0997a2270
MD5 d3e29423c4e3e4afafd899918084d735
BLAKE2b-256 d4d970c47692a1fd10b0531155f3a30bbe9244a7317d64f90c0213d9c41607fe

See more details on using hashes here.

Provenance

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