by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 06:03
    esraa95mahmoud commented #1698
  • Aug 06 20:14
    marcgarreau labeled #1700
  • Aug 06 20:13
    marcgarreau commented #1700
  • Aug 06 15:51
    kclowes closed #1698
  • Aug 06 15:51
    kclowes commented #1698
  • Aug 06 15:50
    MatthiasLohr commented #1490
  • Aug 06 15:23
    kclowes commented #1701
  • Aug 06 11:51
    esraa95mahmoud commented #1698
  • Aug 06 07:01
    esraa95mahmoud commented #1698
  • Aug 06 06:47
    nolash edited #1701
  • Aug 06 06:46
    nolash edited #1701
  • Aug 06 06:44
    nolash opened #1701
  • Aug 06 05:24
    nolash edited #1700
  • Aug 06 05:23
    nolash edited #1700
  • Aug 06 05:23
    nolash opened #1700
  • Aug 03 21:32
    pipermerriam commented #1699
  • Aug 03 20:18
    pipermerriam commented #1699
  • Aug 03 20:03
    pipermerriam commented #1698
  • Aug 03 19:36
    pipermerriam commented #1699
  • Aug 03 19:18
    pipermerriam commented #1699
brschkv
@brschkv

@brschkv Maybe add another parameter to validate or not. Default is validating.

I think web3.js does validate ABIs, too. It just does it differently, which I think is a problem. Will look into how and if web3.js does it later today.

Mikko Ohtamaa
@miohtama
@brschkv can you share the light on the issue why the underlying ABIs have multiple colliding functions in the first place?
It would be useful to understand how widespread this issues is
Voith Mascarenhas
@voith
I’m curious to know to know how you generated your ABI @brschkv. if you’re using solidity your smart contract shouldn’t have compiled because you have coliding functions with the name admin.
Abhishek Kumar
@kuabhish
@kuabhish
Hello Guys, I am having problem in signing and verifying micropayments in web3.py : https://stackoverflow.com/questions/62117851/message-signing-and-verification-for-micropayment-channel
Please help .
brschkv
@brschkv
@miohtama @voith I can't speak to why the contract has colliding functions (lacking the technical knowledge, I guess). What I'm trying to do is use this pre-compiled contract from Compound: https://compound.finance/docs/abi/ropsten/Comptroller . And I can load and interact with it just fine in web3.js. The vendor and the web3.js "compatibility" make me believe that this should be a valid contract.
Mikko Ohtamaa
@miohtama
@brschkv might be worth to reach out to Compound and ask
@brschkv Can you tell me which functions have duplicate signatures?
Voith Mascarenhas
@voith
@brschkv Thanks for the abi. I will test it myself.
May be in a couple of hours
Mikko Ohtamaa
@miohtama
I have some Compound people connected, as they were judges in hackathon I took part
Voith Mascarenhas
@voith
@miohtama from the traceback it seems like admin has multiple occurrences.
I’m curious because that validation code was added by me long back and this is the first time I have seen someone encounter it.
Mikko Ohtamaa
@miohtama
hahaha
Voith Mascarenhas
@voith
@brschkv Are you sure the abi is correct? The abi actually has the function admin repeated 3 times
{
    "constant": true,
    "inputs": [],
    "name": "admin",
    "outputs": [
        {
            "internalType": "address",
            "name": "",
            "type": "address"
        }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function",
    "signature": "0xf851a440"
}

{
    "constant": true,
    "inputs": [],
    "name": "admin",
    "outputs": [
        {
            "internalType": "address",
            "name": "",
            "type": "address"
        }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function",
    "signature": "0xf851a440"
}

{
    "constant": true,
    "inputs": [],
    "name": "admin",
    "outputs": [
        {
            "internalType": "address",
            "name": "",
            "type": "address"
        }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function",
    "signature": "0xf851a440"
}
Might be worth filing an issue with Compound.
Mikko Ohtamaa
@miohtama
@voith Is it the same contract?
Voith Mascarenhas
@voith
Not sure about the smart contract. I was checking the abi @brschkv gave me:
https://compound.finance/docs/abi/ropsten/Comptroller.
If I knew which smart contract it is then I could have compiled and checked their abi.
Their mainnet ABI too looks the same:
https://compound.finance/docs/abi/mainnet/Comptroller
Voith Mascarenhas
@voith
https://github.com/compound-finance/compound-protocol/blob/master/contracts/Comptroller.sol
This seems to be the smart contract. I’ll try to compile it and check.
brschkv
@brschkv

@brschkv Are you sure the abi is correct?

Yes, that is the abi I have used and successfully loaded into web3.js

Voith Mascarenhas
@voith
@brschkv Did you try calling the admin function?
brschkv
@brschkv

@brschkv might be worth to reach out to Compound and ask

I reached out to compound on their dev channel before opening the issue on github and their opinion was that this "looks like an issue with web3.py/abi loading"

Voith Mascarenhas
@voith
I see thanks for the info. I’ll take it from here.
brschkv
@brschkv

@brschkv Did you try calling the admin function?

web3.js from the nodejs repl

comptroller.methods.admin().call()

output:

'0x18646F4a178404b1c986390Ac808236D37229A11'

I see thanks for the info. I’ll take it from here.

As I said in the ticket, I'd be glad to help if you need it. I would just need some starting help as I am fairly new to web3. Comfortable with python, though.

Voith Mascarenhas
@voith
Thanks I will let you know.
Struggling with upgrading my solidity version at the moment :P
Mikko Ohtamaa
@miohtama
When Solidity 1.0
still much beta
Abhishek Kumar
@kuabhish

behaviour of web3py and solidity.

Samples:

## First in web3py

sig = Web3.soliditySha3(somthing .. ) ## used below also
output: HexBytes('0x3efb3cf4e41109f6f1f998401d02dbe894719a8806f45e79a5fab7d4799f00bb')
from eth_account.messages import encode_defunct
msg = sig.hex()
message = encode_defunct(text=msg)
signed_message = w3.eth.account.sign_message(message, private_key=private_key)
signed_message

SignedMessage(messageHash=HexBytes('0x4c0c7077f770069785167e8b7451d63fad1e858ef5251b239eb0781c314000d2'), r=5665764915496639843348851536709769469640799172147461427941649091688603148258, s=48121517563314450138554207713326165180739298862566159641495137088718857193470, v=27, signature=HexBytes('0x0c86b594baa5bb06a0f4054ffdf3896377cfb757d42dcaeacf0241d96a4d5fe26a63d0514338ec600c89ee808dc088e7b3aadc55b9f5d86685d3ff212e2e47fe1b'))

Then I tried

w3.eth.account.recoverHash(signed_message.messagehash,signature=signed_message.signature)#gives correct contract address as output

But when I use:

w3.eth.account.recoverHash(sig,signature=signed_message.signature) ## gives incorrect address

But it gives the same address which solidity is giving...

then I checked what is the output of keccak256(abi.encodePacked(..)).
I found It is same as sig value

and then the ecrecover output of solidity gives the same address given by the above function..

Please help..

Voith Mascarenhas
@voith
@miohtama @brschkv I compiled the solidity contract. Here’s the output of the ABI:
https://gist.github.com/voith/4cc9e10b329e0a4a890d73a7918e8657
Notice that there is just one admin function.
Clearly the abi provided in their documentation is incorrect
Here’s the output of admin function using web3.py:
In [19]: contract.functions.admin().call()
Out[19]: ‘0x18646F4a178404b1c986390Ac808236D37229A11’
@brschkv Please use the ABI provided in my gist and run your code again
Eth-Gitter-Bridge
@Eth-Gitter-Bridge
<carver> Yeah, I agree with @voith here: their ABI is broken, and they didn't notice because web3.js wasn't validating that particular type of input failure
brschkv
@brschkv

@brschkv Please use the ABI provided in my gist and run your code again

Works. Thanks for effort!

<carver> Yeah, I agree with @voith here: their ABI is broken, and they didn't notice because web3.js wasn't validating that particular type of input failure

Wow... So how does one communicate this to Compound?

Mikko Ohtamaa
@miohtama
Let me see if I can reach out to someone
Abhishek Kumar
@kuabhish
Hi guys, I am not able to verify a signed message with ecrecover in solidity
sig = Web3.soliditySha3([address, uint8], [recipientaddress, token] )
msg = sig.hex()
message = encode_defunct(text=msg)
signed_message = w3.eth.account.sign_message(message, private_key=private_key)
signed_message
msg = sig.hex()
message = encode_defunct(text=msg)
signed_message = w3.eth.account.sign_message(message, private_key=private_key)
signed_message
in the contract I want the user to pass arguments like .. numf tokens..and th n i will create a hash with solidity keccak256(abi.encodePacked()))
but the address recovered is coming wrong
Please help
Voith Mascarenhas
@voith
@kuabhish Your issue seems to be to more of a solidity issue and not a web3.py issue.
Try using the remix IDE to debug your smart contract.
Abhishek Kumar
@kuabhish
@voith I did some debugging ..and found that sig = Web3.soliditySha3([address, uint8], [recipientaddress, token] ) and keccak256(abi.encodePacked())) gives the same hash
but sig = Web3.soliditySha3([address, uint8], [recipientaddress, token] ) is not a signed message right? So I send the signed_message.singature as sign and along with arguments which I used in sig = Web3.soliditySha3([address, uint8], [recipientaddress, token] ).. but it doesn't work
Eth-Gitter-Bridge
@Eth-Gitter-Bridge
<carver> I recommend getting really familiar with all the examples on this page: https://web3py.readthedocs.io/en/stable/web3.eth.account.html -- they should help clear up the confusion here. There are examples for preparing a signature to be verified by a solidity contract, also.
Abhishek Kumar
@kuabhish
@Eth-Gitter-Bridge I have used this documentation to familiarize myself.
But I want to :
Lets say :
function withdraw(address recipientaddress, uint25 tokens ){
message = keccak256(abi.encodePacked(token,recipientaddress));
        (uint8 v, bytes32 r, bytes32 s) = splitSignature(sig);
        address signer = ecrecover(message, v, r, s);
    if signer == owner:## owner -- my address
        payment();
}
Abhishek Kumar
@kuabhish
Then when I send my signature obtained by
sig = Web3.soliditySha3( [uint256, address], [tokens, contractaddress] )
from eth_account.messages import encode_defunct
msg = sig.hex()
message = encode_defunct(text=msg)
signed_message = w3.eth.account.sign_message(message, private_key=private_key)
signed_message
SignedMessage(messageHash=HexBytes('0x4c0c7077f770069785167e8b7451d63fad1e858ef5251b239eb0781c314000d2'), r=5665764915496639843348851536709769469640799172147461427941649091688603148258, s=48121517563314450138554207713326165180739298862566159641495137088718857193470, v=27, signature=HexBytes('0x0c86b594baa5bb06a0f4054ffdf3896377cfb757d42dcaeacf0241d96a4d5fe26a63d0514338ec600c89ee808dc088e7b3aadc55b9f5d86685d3ff212e2e47fe1b'))