首页 > 解决方案 > BSC链上使用合约转账,{'code': -32000, 'message': 'transaction type not supported'}

问题描述

def transfer():  
    web3_server = Web3(Web3.HTTPProvider("https://bsc-dataseed1.binance.org"))
    nonce = web3_server.eth.get_transaction_count("address")
    transaction = {
        'to': 'address',
        'value': 1000000000,
        'gas': 2000000,
        'maxFeePerGas': 2000000000,
        'maxPriorityFeePerGas': 1000000000,
        'nonce': nonce,
        'chainId': 56,
        'type': '0x2',
    }
    signed_txn = web3_server.eth.account.sign_transaction(transaction, 'my private key')
    
    // Send the transaction here
    web3_server.eth.send_raw_transaction(signed_txn.rawTransaction)
    // Error returned after sending transaction
    ValueError: {'code': -32000, 'message': 'transaction type not supported'}
    retval = web3_server.toHex(web3_server.keccak(signed_txn.rawTransaction))
    print(retval)

我想用Web3py调用带有本地密钥的合约来签署交易,在HECO上可以正常使用。但它在 BSC 上失败了

标签: pythonweb3py

解决方案


推荐阅读