How to insert data in a signed message

Hi everyone, I would like to insert this data inside a signed transaction in solidity:

let tokens = 10000
let address = "0x......."

So I want to sign a transaction with that information inside.
Let's say that now I've my transaction signed.
Now I call my contract and pass the message signed as parameter.
It there a way to let the contract know the data inside the signed message?

So I want the contract to return: 10000 and the address

Hi, you can't extract the signed data or message from a signature hash, but what you could do if you need the signature to make sure some parameters are valid, is to receive the parameters and the signature, and prove that that signature was made for those specific parameters, something like:

function verifyParams(
    address user,
    uint8 v,
    bytes32 r,
    bytes32 s,
    uint16 tokens,
    uint16 paramAddress
) public requireOwner {
    bytes32 msgHash = keccak256(abi.encodePacked(tokens, paramAddress));
    require(user == ecrecover(msgHash, v, r, s));
    // rest of the code

is this what you wanted to accomplish using a signature?

Thank you for your answer.
I have another question on signatures.
I'm using keccak256 algorithm on my client to generate valid hashes. This gives me an output of 66 characters
So for example:

let messageHashed = EthCrypto.hash.keccak256(messageToSign);
const signature = EthCrypto.sign(privateKeyOwner, messageHashed);

The length of the signature string is 66 characters. So for example:


I would like to obtain a longer string (the content is not important here, I just want to have a longer for example instead of having a 66 long string I need a 200 long string), so for example:


Then pass this to the contract and verify if it was signed by the owner of the contract.
Is this possibile?

Keccak256 always returns an bytes32 and is fixed.
If you would want a longer string you could split it up in 2 seperate seperate keccak256 calculations and append those together and split it up before you decode them and in your contract