Skip to main content

useReportTransactionEffects

Use the useReportTransactionEffects hook can be used to report the effects of a transaction to the connected wallet. The useSignAndExecuteTransaction hook automatically reports effects, and the useSignTransaction hook provides a reportTransactionEffects callback to report effects manually, so this hook is only needed when using a non-standard flow for executing transactions.

Live Editor
function UseReportTransactionEffectsExample() {
    const { mutateAsync: reportTransactionEffects } = useReportTransactionEffects();
    const [signature, setSignature] = useState('');
    const currentAccount = useCurrentAccount();

    return (
        <div style={{ padding: 20 }}>
            {currentAccount && (
                <>
                    <div>
                        <button
                            onClick={async () => {
                                const { effects } = await executePreSignedTransaction();
                                reportTransactionEffects({ effects });
                            }}
                        >
                            Sign empty transaction
                        </button>
                    </div>
                    <div>Signature: {signature}</div>
                </>
            )}
        </div>
    );
}
Result
Loading...

Arguments

  • effects: The effects of an executed transaction. This can either be the rawEffects returned from the JSON-RPC executeTransaction method (returned when showRawEffects is set to true), or the effects.bcs when executing with the GraphQL API.
  • chain: (optional) The chain identifier the transaction was executed on.
  • account (optional) the account that signed the transaction, defaults to the currently connected account