Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
Unable to recover the signed message in Solidity

I am signing a message off-chain and trying to recover this via solidity(on-chain). Somehow, the signer address never matches.

Off-chain code

var message = 'Hello World';
var privateKey = '0xXXXXXXXX'; //Private key of the my using to sign message
var signatureMessage = web3.eth.accounts.sign(message, privateKey);

This gives me a signature value, however, when I am using the same signature and message on solidity to recover the singer's public address, I am getting a different address.

Solidity

function publicSaleBuy(bytes calldata signature, string memory message) external payable
    {
        if (!matchAddresSigner(hashTransaction(message), signature)){
            revert DirectMintFromNotAllowed();
        }else {
            _mint(1);
        }

    }

    function matchAddresSigner(bytes32 hash, bytes memory signature)
        private
        view
        returns (bool)
    {
        return signerAddress == hash.recover(signature);
    }

    function hashTransaction(string memory message) public pure returns (bytes32) {
        bytes32 messageHash = keccak256(abi.encodePacked(message));
        bytes32 hash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", messageHash));        
        return hash;
    }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!