I was wondering If I can sign a message offchain with privatekey, for example using tweetnacl and then send it as an argument to a smart contract. The contract would decide if the message is legit and use the data.

This is the signed message:

    const signFinalPrice = async (price) => {
    const message = Buffer.from(price, 'utf8');
    const signature = nacl.sign.detached(message, privateKey);
    return bs58.encode(signature);

2 Answers 2


I think it's a kind of incorrect use case to check signature for a signed message in smart contract. It's more likely a use case for offchain backend.

If you would like to check signature for specific message in smart contract, why don't you just send message as an arg of instruction and check signer of your public key? You are the signer of the transaction so you can verify signer signed for the price (message) argment in the instruction.


I think you should be able to use the Ed25519 Program https://docs.solana.com/developing/runtime-facilities/programs#ed25519-program

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.