1

Why is the gas fee not working? If I remove the gas fee, the transaction works. But if I add a gas ffee, the transaction fails and returns error:

{'code': -32000, 'message': 'intrinsic gas too low'}

web3matic = Web3(Web3.HTTPProvider(matic))

                    nonce = web3matic.eth.get_transaction_count(walletAddress)
                    result = contract.functions.buy(item, int(price)).buildTransaction({
                        'from': walletAddress,
                        'nonce': nonce,
                        'gas': 21000,
                        'gasPrice': web3matic.toWei(700, 'gwei'),
                    })
                    print(result)

1 Answer 1

1

the issue is 'gas': 21000, 21000 is the minimum amount of gas required for any transaction, depending on the complexity of your smart contract it can go to > 1,000,000.

Gas limit refers to the maximum amount of gas you are willing to consume on a transaction

21000 is the minimum amount of gas an operation on Ethereum will use.

So since the Gas limit represents the maximum amount of gas your operation can use and your function needs more than 21000, you must either remove this value (it will be calculated automatically) or increase it.

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.