Web: Help fix this web3py signed message that will not validate in solidity.

Created on 13 Mar 2021  Â·  14Comments  Â·  Source: gitcoinco/web

The scope of this bounty is to help me understand why a signed message from web3py will not validate in this PR.

i am working on a project that will gitcoin to issue a NFT called sybilpassport that allows a user to carry their Gitcoin TrustBonus across web3-enabled sites. i've got a WIP PR that partially implements this here.

im stuck tho! the signed message is created here with web3==4.5.0 w3.eth.account.signHash , and validated here in solidity. i can get the message to validate in the js hardhat tests, so i know its working, i just can't figure out how to get web3py signed messages to work.

i will offer 0.4 ETH to anyone who can help me solve it.

rules

  1. first come first serve.
  2. a valid submission is a PR to https://github.com/gitcoinco/NFTPOC/ and/or to https://github.com/gitcoinco/web/pull/8478/
  3. a valid submission must use web3==4.5.0 and must sign a message in python backend that is validated by the solidity contract

Most helpful comment

seems like @iRhonin got it all; thanks everyone for participating.

https://github.com/gitcoinco/web/pull/8584

@iRhonin did you build upon the work that @developerfred or others did? id like to reawrd any upstream work that contributed to your fix.

All 14 comments

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__This issue now has a funding of 0.4 ETH (706.58 USD @ $1766.44/ETH) attached to it.__

@owocki do you need use V5 https://web3py.readthedocs.io/en/latest/web3.eth.account.html#sign-a-message

from eth_account import Account, messages

msg_hash_hex = "058c3b4c8e5dc4632b5c6b861b2c1861d53e426dc673c907ddf2651942b0f230"
private_key_hex = "b25c7db31feed9122727bf0939dc769a96564b2de4c4726d035b36ecf1e5b364"

#// This part prepares "version E" messages, using the EIP-191 standard
message = messages.encode_defunct(hexstr=msg_hash_hex)

#// This part signs any EIP-191-valid message
signed_message = Account.sign_message(message, private_key=private_key_hex)
print("signature =", signed_message.signature.hex())`

ref: https://ethereum.stackexchange.com/questions/72714/analogue-web3-eth-accounts-sign-from-web3js-in-web3py

lib: https://github.com/ethereum/eth-account

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__Work has been started__.

These users each claimed they can complete the work by 265 years, 8 months from now.
Please review their action plans below:

1) developerfred has started work.

this solution is migrate web3 to v5
https://github.com/gitcoinco/web/issues/8571#issuecomment-797855429
ref: https://web3py.readthedocs.io/en/stable/v5_migration.html
2) bacdayhx has started work.

Toi sẽ lam đươc yên tam tôi nhé
3) iamonuwa has started work.

The issue is the version of web3 used. Worked on this with v4 and v5. v5 Worked.
4) irhonin has started work.

Reading web3py doc and setup my own contract and test with that.
5) cryptomalo has started work.

How I can help you? I work with graphic designer
6) mhrann has started work.

beaconcha.in
Epochs
Blocks
Validators
Stats
Dashboard
Services
7) armythai8710 has started work.

https://twitter.com/SUPACHAI_ARMY/status/1374791278357934086?s=19

Learn more on the Gitcoin Issue Details page.

@developerfred id have to upgrade a lot of other parts of the site in order to upgrade to v5 (which is not out of the question but its just a lot to manage). is there not a signing message in web3==4.5.0 we can use?

does the code snippet you posted work with the solidity contract i posted? are you sure?

@developerfred oh wait are you talking about eth_account v5 or web3py v5? your code indicates that eth_account is needed but your comment seems to indicate web3py

we are on eth-account==0.2.1 o the servers and web3==4.5.0

hmm from testing , it looks like eth-account==0.5.4 is sufficient to get teh above code to run, although that seems to break web3py, which may relies upon a pinned version of eth-account?

two ways we could solve this:

  • install a second version of eth-account and run both 0.2.1 and 0.5.4 under different namespaces
  • bite the bullet and upgrade web3py to the latest version

i think id lean towards the second one. though we'd need to do a full replace of the web3 code across the site to make sure it upgrades

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__Work for 0.4 ETH (709.64 USD @ $1873.7/ETH) has been submitted by__:


hmm from testing , it looks like eth-account==0.5.4 is sufficient to get teh above code to run, although that seems to break web3py, which may relies upon a pinned version of eth-account?

two ways we could solve this:

  • install a second version of eth-account and run both 0.2.1 and 0.5.4 under different namespaces
  • bite the bullet and upgrade web3py to the latest version

i think id lean towards the second one. though we'd need to do a full replace of the web3 code across the site to make sure it upgrades

I also lean towards updating web3py, we have to do that at some point.

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__Work for 0.4 ETH (665.41 USD @ $1687.9/ETH) has been submitted by__:

  1. @bacdayhx
  2. @irhonin
  3. @developerfred

@owocki please take a look at the submitted work:

  • PR by @developerfred
  • PR by @irhonin
  • PR by @bacdayhx

seems like @iRhonin got it all; thanks everyone for participating.

https://github.com/gitcoinco/web/pull/8584

@iRhonin did you build upon the work that @developerfred or others did? id like to reawrd any upstream work that contributed to your fix.

thank you @owocki.
the link @developerfred mentioned was useful https://github.com/gitcoinco/web/issues/8571#issuecomment-797855429.

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__The funding of 0.4 ETH (675.16 USD @ $1687.9/ETH) attached to this issue has been approved & issued to @developerfred.__

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__The funding of 0.4 ETH (675.16 USD @ $1687.9/ETH) attached to this issue has been approved & issued to @developerfred.__

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__The funding of 0.4 ETH (675.16 USD @ $1687.9/ETH) attached to this issue has been approved & issued to @developerfred.__

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kuhnchris picture kuhnchris  Â·  4Comments

sethmcleod picture sethmcleod  Â·  4Comments

thelostone-mc picture thelostone-mc  Â·  4Comments

christianbundy picture christianbundy  Â·  3Comments

wizzfile picture wizzfile  Â·  3Comments