Track Transactions
Package: @decent.xyz/box-hooks
Hook: useTxnStatus
Decent operates a scanner that enables developers to easily track and analyze all of their transactions. The useDecentScan
hook is built on the Decent Scan API's.
The useDecentScan
hook leverages SWR for efficient polling. This does introduce swr
as a peer dependency.
Types
TxStatusArgs
Please refer to the ChainId
type in the Box Common types glossary.
type TxnStatusArgs = {
srcTxHash: ChainId;
srcChainId: string;
};
Sample Request & Implementation
export async function sendDecentTransaction({
txConfig,
}: {
txConfig: BoxActionRequest;
}) {
const [hash, setHash] = useState();
const [txReceipt, setTxReceipt] = useState();
const { actionResponse, isLoading, error } = useBoxAction(txConfig);
const { hash } = await sendTransaction(actionResponse?.tx);
setHash(hash);
const { data, isLoading } = useDecentScan({
srcTxHash: hash,
srcChainId: txConfig.srcChainId,
});
}