Mutation hook for sending transactions using a Viem WalletClient from useParaViemClient.
Requires @getpara/viem-v2-integration and viem as peer dependencies.
Import
import { useParaViemSendTransaction } from "@getpara/react-sdk";
Usage
import { useParaViemClient, useParaViemSendTransaction } from "@getpara/react-sdk";
import { sepolia } from "viem/chains";
import { http, parseEther } from "viem";
function SendTransaction() {
const { viemClient } = useParaViemClient({
walletClientConfig: { chain: sepolia, transport: http() },
});
const { sendTransactionAsync, isPending, data: txHash } = useParaViemSendTransaction(viemClient);
return (
<button onClick={() => sendTransactionAsync({ to: "0x...", value: parseEther("0.01") })} disabled={isPending}>
{isPending ? "Sending..." : "Send ETH"}
</button>
);
}
mutate/mutateAsync are also available alongside the named aliases. All other UseMutationResult fields (data, error, isSuccess, isError, reset, etc.) work as expected.