【发布时间】:2022-01-04 01:59:17
【问题描述】:
我试图在 Binance Smart Chain 中将交易从一个账户发送到另一个账户,但出现错误
ValueError: {'code': -32000, 'message': 'transaction type not supported'}
这是我的代码
from web3 import Web3
REF_ADDRESS = '0x5...'
MY_ADDRESS = '0xe...'
MY_PKEY = 'd...'
MAX_GAS_ETHER = 0.0005
web3 = Web3(Web3.HTTPProvider('https://bsc-dataseed.binance.org/'))
balance = web3.eth.get_balance(MY_ADDRESS)
gas_price = float(web3.fromWei(web3.eth.gas_price, 'ether'))
allowed_gas = int(MAX_GAS_ETHER/gas_price)
print(web3.fromWei(balance, 'ether'))
tx = {
'from': MY_ADDRESS,
'to': REF_ADDRESS,
'value': web3.toWei(0.0001, 'ether'),
'gas': allowed_gas,
'type': 2,
'chainId': web3.eth.chain_id,
'maxFeePerGas': web3.toWei(5, 'gwei'),
'maxPriorityFeePerGas': web3.toWei(2, 'gwei'),
'nonce': web3.eth.get_transaction_count(MY_ADDRESS),
}
tx_signed = web3.eth.account.sign_transaction(tx, MY_PKEY)
tx_hash = web3.eth.send_raw_transaction(tx_signed.rawTransaction)
tx_receipt = web3.eth.wait_for_transaction_receipt(tx_hash)
请帮我弄清楚我做错了什么
【问题讨论】:
标签: python binance-smart-chain web3py