I am trying to call a function on a contract on the FTM network using web3.py. My code runs, and the final call to sendRawTransaction returns a tx id, but it never makes it to any of the nodes. Can anyone point me in the right direction? Thanks!
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://rpc.ftm.tools/'))
w3.eth.blockNumber # Test, successful
my_addy = w3.toChecksumAddress('0xxxx')
contract_addy = w3.toChecksumAddress('0xxxx')
abi = '''xxx'''
contract = w3.eth.contract(contract_addy, abi=abi)
signed_txn = w3.eth.account.signTransaction({
'nonce':w3.eth.get_transaction_count(my_addy)+ 3,
'from':my_addy,
'to':caddy,
'gas':98340,
'gasPrice':Web3.toWei(106.3613, "gwei"),
'value':Web3.toWei(0, "ether"),
'data': contract.encodeABI(fn_name="funcation_name", args=[123]),
'chainId':250,
},
'XXprivate_keyXX'
)
x = w3.eth.sendRawTransaction(signed_txn.rawTransaction)
> x # tx id is being returned, but never makes to a node
HexBytes('0x4xxxxxxx6')
w3.eth.get_transaction_count(my_addy)+ 3
to set the nonce?'nonce':w3.eth.get_transaction_count(my_addy)
should work. If you don't have any pending transactionget_transaction_count
returns the next nonce.