Gnosis Safe – How to Identify Rejected Transactions Using Core-SDK

gnosis-safesafe-core-sdk

I am using the safe-core-sdk to propose transactions to the Gnosis Safe Transaction Service.

When the transaction has been proposed, I am then checking frequently via a job whether the transaction has been executed, and successful. I am doing this by using getTransaction, part of the safe-service-client, which returns some transaction object of type SafeMultisigTransactionResponse.

The issue I am having, is when I reject a transaction via the Safe UI, and then get the tx, there is no indication that the transaction has been rejected. The isExecuted property is false, and the isSuccessful property is still null. The safe tx hash in the UI for the on chain rejection, is also different to the safe tx hash for the proposed transaction.

Is there a way I can verify that a transaction has been rejected via the sdk?

Cheers

Best Answer

It's actually impossible to reject a transaction in the Ethereum network. What happens under the hood when rejecting is that you create a transaction that uses the same nonce as the transaction you want to reject and 0 value and empty data. Once such transaction is executed, the Safe nonce is incremented and cannot be re-used anymore, making previous signatures useless (nonce is the part of transaction hash you sign).

To know if the transaction has been rejected, you can check that the Safe's nonce is greater than the transaction nonce and the isExecuted flag is false. To check if the transaction is being rejected or replaced you need to check if there is a pending transaction with the same nonce.