> ## Documentation Index
> Fetch the complete documentation index at: https://docs.p2p.org/llms.txt
> Use this file to discover all available pages before exploring further.

# verifyTransaction()

> Perform some checks on a staking transaction.

This method is intended to be called on a `Transaction` after it was signed by an external software or hardware wallet. This mitigates the risk of data being altered by third parties.

If possible, it is recommended to call this method with the same data that was passed to [`stake()`](/docs/staking-sdk-solana-stake).

<Note>
  **Example**

  A popular attack involves altering the content of the system clipboard when a user is copying the transaction data to their software wallet. A malicious software on a user's computer could replace the legitimate staking transaction with another transaction that sends funds to a third party. The user then signs the malicious transaction without noticing.

  By calling `verifyTransaction()`, you can detect that the transaction that was signed is not, in fact, the expected staking transaction.
</Note>

<CodeGroup>
  ```javascript JavaScript theme={null}
  client.solana.verifyTransaction({
    tx: signedTx,
    expectedFeePayer: authority,
    expectedStakeAuthority: authority,
    expectedWithdrawAuthority: authority,
    strict: true,
  });
  ```
</CodeGroup>

## Checks

The following checks are performed.

* The transaction must have a fee payer. If `expectedFeePayer` is provided, the transaction must have this exact fee payer.
* The transaction must contain instructions. If the strict mode is on, each instruction must be either a [`StakeProgram`](https://solana-foundation.github.io/solana-web3.js/classes/StakeProgram.html) or a [`SystemProgram`](https://solana-foundation.github.io/solana-web3.js/classes/SystemProgram.html).
* If the strict mode is on, both `expectedStakeAuthority` and `expectedWithdrawAuthority` (if provided) must be referenced in at least one instruction each.

## Parameters

|                                                                                                                                     |
| ----------------------------------------------------------------------------------------------------------------------------------- |
| **tx** *Transaction, required*<br />The signed transaction that needs to be verified.                                               |
| **expectedFeePayer** *string*<br />The `feePayer` that was passed to [`stake()`](/docs/staking-sdk-solana-stake) .                  |
| **expectedStakeAuthority** *string*<br />The `stakeAuthority` that was passed to [`stake()`](/docs/staking-sdk-solana-stake).       |
| **expectedWithdrawAuthority** *string*<br />The `withdrawAuthority` that was passed to [`stake()`](/docs/staking-sdk-solana-stake). |
| **strict** *boolean*<br />If true, some additional checks will be enabled. See the list of checks above for more information.       |

## Result

If the transaction is correct, the method does not return anything. It is assumed that you can safely publish the transaction via [`sendTransaction()`](/docs/staking-sdk-solana-sendtransaction).

If the transaction is not correct, the method throws an `Error` with the corresponding message. It is strongly recommended to discard such a transaction and investigate whether the system is compromised.


## Related topics

- [sendTransaction()](/docs/staking-sdk-solana-sendtransaction.md)
- [Staking API reference](/reference/solana-staking-stake.md)
