0

Sorry about the formatting, I’m on mobile

I'm trying to push an ERC20 Token transaction with 0 gas price using web3.py. Although when I set the gas price to 0, I receive the following error:

{'code': -32000, 'message': 'transaction underpriced'}

I know 0 gas price transactions are possible because I’ve seen plenty of them.

Code:

nonce = web3.eth.getTransactionCount(account)

txn = contract.functions.transfer(to_address, amount).buildTransaction(
  {
    'chainId': 1,
    'gas': 1000000,
    'gasPrice': web3.toWei("0", "gwei"),
    'nonce': nonce,
  }
)
signed_txn = web3.eth.account.signTransaction(txn, private_key=account_priv_key)

tx_hash = web3.eth.sendRawTransaction(signed_txn.rawTransaction)

And I need the transaction to be a 0 gas price. Any help would be great thanks.

8
  • Contract transactions need gas. Calls are free. – Veilkrand Jan 15 '20 at 13:32
  • 1
    That error message is from the node, it is configured to not accept transactions below certain price. – Ismael Jan 15 '20 at 13:34
  • @Veilkrand but what about transactions such as this : etherscan.io/tx/… – manilpwn Jan 15 '20 at 13:35
  • @Ismael can I change the node somehow to a node which accepts 0 price? Or can I set up my own to do that? – manilpwn Jan 15 '20 at 13:36
  • 1
    For reference on zero gas transaction in main net: medium.com/chainsecurity/… – Veilkrand Jan 15 '20 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.