Trying to call a function that takes a parameter from my contract on BSC. The parameter is an address. The signing of the transaction goes well but when I get to send_raw_transaction I get hit with "'str' object has no attribute 'request_func'".
Using send_transaction alone gives off this error : "a bytes-like object is required, not 'str'"
import json
from web3.auto import w3
from web3.middleware import geth_poa_middleware
from web3 import Web3
# Set up the connection to the network.
bsc = Web3(Web3.HTTPProvider('https://bsc-dataseed.binance.org/'))
bsc.middleware_onion.inject(geth_poa_middleware, layer=0)
print(bsc.isConnected())
w3 = Web3('https://bsc-dataseed.binance.org/')
nonce = bsc.eth.get_transaction_count('ADDRESS_ETC')
hex_string = bytes.fromhex('ADDRESS_ETC')
privateKey = "PRIVATE_KEY_ETC"
account = w3.eth.account.privateKeyToAccount(privateKey)
unicorn_txn = contract.functions.myFunction(
hex_string
).build_transaction({
'chainId': 56,
'gas': 70000,
'maxFeePerGas': w3.toWei('2', 'gwei'),
'maxPriorityFeePerGas': w3.toWei('1', 'gwei'),
'nonce': nonce,
'from': account.address,
})
print(unicorn_txn)
signed_txn = w3.eth.account.sign_transaction(unicorn_txn, private_key=privateKey)
signed_txn.rawTransaction
signed_txn.r
signed_txn.s
signed_txn.v
w3.eth.send_transaction(signed_txn.rawTransaction)
Expected the transaction to go through, it didn't