Skip to Content
Privacy Protocol relayer flow is now default in the SDK.
DocsReact Hooks

React Hooks

Import from:

import { useDeposit, useExecuteAction, useWithdraw, usePrivateTransactionDetails, } from "privacy-protocol/hooks";

Base config:

const config = { poolAddress, provider, signer };

Relayer config is optional. Hooks use SDK defaults unless you pass relayer.

useDeposit

const { deposit, note, isPending, error } = useDeposit(config); const depositResult = await deposit({ token, amount });

useExecuteAction

const { executeAction, nextNote, isPending, error } = useExecuteAction(config); const result = await executeAction({ token, amount, target, data, secret: depositResult.secret, nullifier: depositResult.nullifier, amountInPool: amount, });

useWithdraw

const { withdraw, nextNote, isPending, error } = useWithdraw(config); await withdraw({ token, recipient, amount, note });

usePrivateTransactionDetails

const [privateTxHash, setPrivateTxHash] = useState<string>(); const { data, isLoading } = usePrivateTransactionDetails({ ...config, txHash: privateTxHash, });

Use this to display queued, submitted, and confirmed transaction states.

Last updated on