I was wondering how is it possible to show a message while signing an anchor transaction since it creates a transaction by itself unlike how you do using @solana/web3.js. I just want to let user know why he/she is signing the transaction.

For eg:

const tx = await program.methods.initialize().accounts({
       baseAccount: programPDA,
       authority: user.publicKey

So the above the method would direcly open the mobile wallet and ask the user to sign. But along with this i want to show the message why the person has to sign. A message like this Sign the transaction to initialize the PDA while signing the tx is what i want.

Can anybody tell me how is this possible?

  • 5
    I suspect this isn't possible as it would provide a legitimate looking mechanism for scammers to trick users into signing malicious transactions. Perhaps consider a different UX flow where the user is presented with your message before the transaction is passed to the wallet. Be sure to wait until after the user proceeds to query a recent blockhash, otherwise a slow user's transactions may expire
    – trent.sol
    Jul 16, 2022 at 5:18

1 Answer 1


As Trent mentioned, it is not possible.

Best practice is let them know beforehand. There could be popup that says something like:

Looks like you haven't been using SuperApp before.
We are creating a SuperApp account for you.
This will involve a small fee payable in SOL and
approving a transaction in your wallet.

                       [ Got It ]

And then afterwards sending the initialize instruction.

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.