0

So I am trying to use a method directly on etherscan.io (using "Write Contract" on the contract whose method I am trying to use) and it asks me for some parameters. Some of the parameters require me to input "v", "r" and "s" values for me to use this method (just to add, this method is for swapping some tokens); however, how would I know the v, r, s values of the transaction before I have even sent it? To add to this, I have checked other people's inputs (who have used the method multiple times) on tenderly, and when they have used this method, each time their v, r, s input values for the parameters to this method are the same on each of the occasions that these people have used the method. Am I missing something? Do user's addresses have their own specific v, r, s values tied to them that never changes, and is that what I am supposed to use as an input for this method? Am I not supposed to be using the v, r and s values of the transaction itself, but of something else instead, if so, what is that something else?

I have read through multiple docs and ethstack questions related to v, r, s and things like 'ecrecover' to try and understand what I am supposed to input, but alas to no avail. Any ideas of what I am supposed to use here for the parameters?

Thank you,

PostTraumaticDesk

5
  • 1
    Do you have the contract source code? The v, r and s are part of an ECDSA signature. To calculate them you need to determine what is the message to be signed.
    – Ismael
    Commented Jul 21, 2021 at 17:29
  • @Ismael I do have the contract source code, the method is written like this: exampleMethod(address sender, uint8 v, bytes32 r, bytes32 s) . What i am asking is how do i get these v, r and s values before hand, to input and use for this method. Commented Jul 21, 2021 at 17:32
  • The transaction's signature also has v, r and s but those are unrelated to the function parameters of the same name. The v, r and s from the function call are necessarily from a different signature.
    – Ismael
    Commented Jul 21, 2021 at 17:41
  • @Ismael Inside of the function i mentioned, the following one is called: function _performCheck(address sender, uint8 v, bytes32 r, bytes32 s) internal view { bytes memory pkd = abi.encodePacked(sender); bytes32 hRes = keccak256(pkd); require(ecrecover(hRes, v, r, s) == signerAddress, "Not properly signed"); } that uses those 3 v, r s values, but I am confused as to what values I am supposed to supply to it. Any ideas? Commented Jul 21, 2021 at 18:05
  • Did you ask the contract's developers? It seems abi.encodePacked(sender) is the message to be signed, but the developers are the ones that should document the desired behavior. Also the developers should be made aware that ecrecover has well documented malleability problems.
    – Ismael
    Commented Jul 21, 2021 at 23:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.