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,
    'gasPrice':Web3.toWei(106.3613, "gwei"),
    'value':Web3.toWei(0, "ether"),
    'data': contract.encodeABI(fn_name="funcation_name", args=[123]),

x = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

> x # tx id is being returned, but never makes to a node
  • Why are you using w3.eth.get_transaction_count(my_addy)+ 3 to set the nonce?
    – Ismael
    Commented Sep 14, 2021 at 23:13
  • oops, that's supposed to be +1 -- cut and paste fail when removing private info from gist. (is +1 correct?)
    – dsldsl
    Commented Sep 15, 2021 at 23:32
  • In most cases 'nonce':w3.eth.get_transaction_count(my_addy) should work. If you don't have any pending transaction get_transaction_count returns the next nonce.
    – Ismael
    Commented Sep 16, 2021 at 2:01
  • Were you able to resolve this? I'm having issues with send_raw_transaction function on fantom as well?
    – MSalty
    Commented Nov 4, 2021 at 6:14

1 Answer 1


Have you tried using build transaction?

contract = w3.eth.contract(contract_addy, abi=abi)

function_txn = contract.functions.**functionname**(
    'nonce':w3.eth.get_transaction_count(my_addy, 'pending'),
    'gasPrice':Web3.toWei(106.3613, "gwei"),
    'value':Web3.toWei(0, "ether"),

signed_txn = w3.eth.account.signTransaction(function_txn,'XXprivate_keyXX')
x = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.