ethereum / web3.py

A python interface for interacting with the Ethereum blockchain and ecosystem.
http://web3py.readthedocs.io
MIT License
5.02k stars 1.71k forks source link

Invalid Field in signTransaction while trying to deploy a contract #2223

Closed robinportigliatti closed 2 years ago

robinportigliatti commented 2 years ago
aiohttp==3.7.4.post0
aiosignal==1.2.0
asgiref==3.4.1
asttokens==2.0.4
async-timeout==3.0.1
attrs==21.2.0
backports.entry-points-selectable==1.1.1
base58==2.1.0
bitarray==1.2.2
bitly-api-py3==0.3
black==21.9b0
certifi==2021.10.8
cffi==1.15.0
cfgv==3.3.1
chardet==4.0.0
charset-normalizer==2.0.7
click==8.0.3
cryptography==35.0.0
cytoolz==0.11.0
dataclassy==0.11.1
distlib==0.3.3
dj-database-url==0.5.0
Django==3.2.9
django-cors-headers==3.10.0
django-crispy-forms==1.13.0
django-debug-toolbar==3.2.2
django-dirtyfields==1.7.0
django-docutils==0.5.1
django-extensions==2.2.9
django-heroku==0.3.1
django-mirage-field==1.2.2
django-qr-code==2.3.0
django-randomslugfield==0.3.0
django-slugify-processor==0.11.0
djangorestframework==3.12.4
docutils==0.18
eip712==0.1.0
eth-abi==2.1.1
eth-account==0.5.6
eth-brownie==1.17.1
eth-event==1.2.3
eth-hash==0.3.2
eth-keyfile==0.5.1
eth-keys==0.3.3
eth-rlp==0.2.1
eth-typing==2.2.2
eth-utils==1.10.0
execnet==1.9.0
filelock==3.4.0
frozenlist==1.2.0
gunicorn==20.1.0
hexbytes==0.2.2
hypothesis==6.24.0
identify==2.4.0
idna==3.3
inflection==0.5.0
iniconfig==1.1.1
ipfshttpclient==0.8.0a2
jsonschema==3.2.0
lazy-object-proxy==1.6.0
lru-dict==1.1.7
lxml==4.6.4
multiaddr==0.0.9
multidict==5.2.0
mypy-extensions==0.4.3
mythx-models==1.9.1
netaddr==0.8.0
nodeenv==1.6.0
packaging==21.0
parsimonious==0.8.1
pathspec==0.9.0
Pillow==8.4.0
platformdirs==2.4.0
pluggy==1.0.0
pre-commit==2.15.0
prompt-toolkit==3.0.21
protobuf==3.19.0
psutil==5.8.0
psycopg2==2.9.2
psycopg2-binary==2.9.2
py==1.10.0
py-solc-ast==1.2.9
py-solc-x==1.1.1
pycparser==2.21
pycryptodome==3.11.0
Pygments==2.10.0
pygments-lexer-solidity==0.7.0
PyJWT==1.7.1
pyparsing==3.0.3
pyrsistent==0.18.0
pytest==6.2.5
pytest-forked==1.3.0
pytest-xdist==1.34.0
python-dateutil==2.8.1
python-dotenv==0.16.0
pythx==1.6.1
pytz==2021.3
PyYAML==5.4.1
regex==2021.10.23
requests==2.26.0
rlp==2.0.1
segno==1.4.0
semantic-version==2.8.5
six==1.16.0
sortedcontainers==2.4.0
sqlparse==0.4.2
toml==0.10.2
tomli==1.2.2
toolz==0.11.1
tqdm==4.62.3
typing-extensions==3.10.0.2
urllib3==1.26.7
varint==1.0.2
virtualenv==20.10.0
vvm==0.1.0
vyper==0.3.0
wcwidth==0.2.5
web3==5.24.0
websockets==9.1
whitenoise==5.3.0
wrapt==1.13.2
yarl==1.7.0

What was wrong?

Hello,

Juste made my first NFT today as a POC :D. But my application is in python (Django) and the migration and mint process are in NodeJs... So I tried your solution but I found some difficulty by deploying my first contract.

When I run the following code I get the following error : Transaction had invalid fields: {'gas': '3000000', 'gasPrice': '70000000000'} But when I remove the invalid fields I get these error : Transaction must include these fields: {'gasPrice', 'gas'}

Do you think it is due to the fact I used arbitrary value ?

Robin,

fselmo commented 2 years ago

@robinportigliatti Thanks for reaching out. I think I can help you debug here. It looks like in this case the message isn't entirely clear. It is the value of your fields that are problematic, not the fields themselves. You are passing them in as string but they need to be int.

Give it a shot with int values instead:

transaction = {
      'data': data,
      'gas': 3000000,
      'gasPrice': 70000000000,
      'nonce': count
  }

I believe this is the error here. I'm going to close this but feel free to re-open if that did not resolve your issue. I'd encourage you to join the discord if you have any usage questions or anything else. We have a great supportive community over there happy to answer and ask questions as things pop up. Good luck!

robinportigliatti commented 2 years ago

@fselmo thank you, it worked, now I have to find why my contract creation is in error

I will join the discord, it might be better you are right