1

I'm trying to verify a signature, but when I decode it, the function reverts. This is the function I'm using

function source(bytes memory signature) public returns (bytes32 r, bytes32 s, uint8 v) {
        (bytes32 r, bytes32 s, uint8 v) = abi.decode(signature, (bytes32, bytes32, uint8));
    }

The encoded signature looks like this (Im encoding it using web3.eth.abi.encodeParameters) and then making an eth_call

  0000000000000000000000000000000000000000000000000000000000000020
  0000000000000000000000000000000000000000000000000000000000000041
  8318875f720f88683b75c949a1e83fcefbd586ae8a8276944f126cdba176f384
  4b05c92d1b4393dcf1dad2d59b88f196c9aba988141265bdacbfdbc90049fa21
  1c00000000000000000000000000000000000000000000000000000000000000

But if I hardcode the signature into the contract like this It seems to work

function source() public returns (bytes32 r, bytes32 s, uint8 v) {
    bytes memory signature = "0x8318875F720F88683B75C949A1E83FCEFBD586AE8A8276944F126CDBA176F3844B05C92D1B4393DCF1DAD2D59B88F196C9ABA988141265BDACBFDBC90049FA211c";
    (bytes32 r, bytes32 s, uint8 v) = abi.decode(signature, (bytes32, bytes32, uint8));
}

Can someone explain to me what is going on and why it happens this way? Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.