This is a library used to use web3.py
on conflux-bridge(?). This library hacks the signing machanism of web3.py
.
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
Import conflux_we3py_signer
before import web3
.
import conflux_web3py_signer
import web3
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
For example, brownie console
usage:
cfx-brownie console --network cfx-testnet-bridge
Check in the console if connected:
>>> network.is_connected()
True
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, usemaxFeePerGas
as gas price. - Fill
epochHeight
withw3.eth.block_number
, which correspondes toepoch_number
in conflux. - Estimate the transaction and fill
storageLimit
from estimate result.
EOA account addresses are all converted to begin with 0x1
and is encoded in checksum format