-
In my smart contract a function can be executed only if signed by an oracle (which validates the data before generating the transaction). The solidity code uses OpenZeppelin's ECDSA.sol and looks like:
The hash is calculated like in this example:
I had hard time to find a way to generate a working signature.
I call it like
I use hardhat for test and deployment, and use the same process to deploy the smart contracts during tests and actual deployment to networks. Problem is that during tests everything works fine, but, when I try to do initialize a mapping during the deployment to localhost:8545 (served by hardhat), the recovered address is not the expected one. I am getting crazy to understand why. Any idea? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I solved it. I modified the smart contract adding a public function that returns the keccak256 of the abi-encoded params.
I get the hash calling the function in the smart contract as
instead that using
as before. It is very weird that ethers formats the data in a slightly different way during test and deployment. It looks like a bug. |
Beta Was this translation helpful? Give feedback.
I solved it.
I modified the smart contract adding a public function that returns the keccak256 of the abi-encoded params.
This way, the ECDSASign changes as:
I get the hash calling the function in the smart contract as
instead that using
as before.
It is very weird that ether…