Tx sender recovery with rsv signatures in Hardhat local network #3369
Unanswered
paul-zibarov
asked this question in
Troubleshooting
Replies: 1 comment 9 replies
-
@paul-zibarov you should also include the code you are using to generate the parameters, and the solidity code that you are using to recover the address. |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello! I am trying to create an on-chain tx sender validator. Smart contract receive tx data (tx.nonce, tx.gasprice, tx.gaslimit, tx.to, tx.value, tx.data), signatures (tx.v, tx.r, tx.s) and sender(tx.from) than rlp encode tx parameters and generate hash which used in solidity ecrecover(hash, r, s, v). This function returns recovered address, which should be equal to tx.from if parameters were encoded correctly and signatures were correct. This solution works on bsc main and test networks, but I want to run some tests in local network and there is some problem with signatures.
I started hardhat local network, then published ERC-20 contract and Verifier contract, then call mint tx from the first generated account. I copied this data and pass it to Verifier and receive zero address as result.
Why I am thinking that there is a problem with signatures?
As offchain alternative I use script that does same things to tx data. I am using these packages:
I copied the private key from the generated account and sign tx.hash with it and received completely other signatures.
There is no problem with hashes, because smart contract and js rlp library generated the same hash. I passed these signatures with hash to ecrecover function and finally received generated account address.
I also tried to send raw tx with offchain-generated signatures and mined tx from a completely different address.
Example data:
My hardhat config:
I would be appreciated any tips or help, cause I am stuck in these tests.
Beta Was this translation helpful? Give feedback.
All reactions