Im working with the Thirdweb Python SDK API. The code below sometimes work and sometimes throws a gasprice issue. I think it could be a network issue, because it works sometimes and generates the NFT but not always.
And when i got an error it is about gasprice. But in the Thirdweb API doesnt appear a gasprice argument or someting like this.
Any ideas?
Code:
sqlcol="SELECT ID,(SELECT contrato FROM colecciones WHERE ID=idcolec) AS contratonft FROM solicitudcert WHERE ID='" + idsolicitud + "' LIMIT 0, 1"
mycursor.execute(sqlcol)
misolicitud = mycursor.fetchone()
if(misolicitud):
contratonft_aux=str(misolicitud[1])
contratonft=contratonft_aux.replace('"','')
sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, NETWORK)
NFT_COLLECTION_ADDRESS = contratonft
nft_collection = sdk.get_nft_collection(NFT_COLLECTION_ADDRESS)
urlarchivoarr=imagencert.split("/")
urlarchivostr=str(urlarchivoarr[1]);
urlarchivoimg="https://files.avfenixrecords.com/" + urlarchivostr
# You can pass in any address here to mint the NFT to
tx = nft_collection.mint(NFTMetadataInput.from_json({
"name": nombrecert,
"description": descripcert,
"image": urlarchivoimg
}))
idnft=tx.id
return jsonify({'status':'OK','IDNFT':idnft})
else:
return jsonify({'status':'ERROR','IDNFT':"NULL"})
Error:
[2022-11-15 19:54:21,628] ERROR in app: Exception on /api/contracts/v1/mintnft [POST]
Traceback (most recent call last):
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/flask/app.py", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/flask/app.py", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/flask/app.py", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/flask/app.py", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "app.py", line 1851, in mintnft
tx = nft_collection.mint(NFTMetadataInput.from_json({
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/thirdweb/contracts/nft_collection.py", line 135, in mint
return self.mint_to(self._contract_wrapper.get_signer_address(), metadata)
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/thirdweb/contracts/nft_collection.py", line 166, in mint_to
receipt = self._contract_wrapper.send_transaction("mint_to", [to, uri])
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/thirdweb/core/classes/contract_wrapper.py", line 113, in send_transaction
tx = getattr(self._contract_abi, fn).build_transaction(
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/thirdweb/abi/token_erc721.py", line 1638, in build_transaction
return self._underlying_method(to, uri).buildTransaction(
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/contract.py", line 1079, in buildTransaction
return build_transaction_for_function(
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/contract.py", line 1648, in build_transaction_for_function
prepared_transaction = fill_transaction_defaults(web3, prepared_transaction)
File "cytoolz/functoolz.pyx", line 249, in cytoolz.functoolz.curry.__call__
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/_utils/transactions.py", line 114, in fill_transaction_defaults
default_val = default_getter(web3, transaction)
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/_utils/transactions.py", line 60, in <lambda>
'gas': lambda web3, tx: web3.eth.estimate_gas(tx),
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/eth.py", line 825, in estimate_gas
return self._estimate_gas(transaction, block_identifier)
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/module.py", line 57, in caller
result = w3.manager.request_blocking(method_str,
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/manager.py", line 198, in request_blocking
return self.formatted_response(response,
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/manager.py", line 171, in formatted_response
raise ValueError(response["error"])
ValueError: {'code': -32000, 'message': 'err: max fee per gas less than block base fee: address 0x98E0463643b28E24223d2B5EF19E78A9AF031505, maxFeePerGas: 70565183066 baseFee: 77047968359 (supplied gas 22141296)'}
I tried to modify the contracts config into the thirdweb dashboard without success.
What network are you seeing this issue on? We can add in a method to manually overwrite gas limits in the SDK.