Lens Blocks are currently in pre-alpha and not ready for use!

Use Tip Account Action Hook

A hook to tip Lens Accounts using the Lens React SDK.

This hook allows users to tip a account using a specified payment source and amount.

Installation

Usage

import { useTipAccountAction } from "@/hooks/use-tip-account-action";
import { useAccount, useSessionClient, PaymentSource, evmAddress, TxHash } from "@lens-protocol/react";
const { execute, error } = useTipAccountAction();
const { data: sessionClient } = useSessionClient();
const { data: walletClient } = useWalletClient();
const account = evmAddress("SOME_ACCOUNT_ADDRESS");
const handleCreateTip = async (source: PaymentSource, amount: string, tokenAddress: string): Promise<TxHash> => {
  if (!sessionClient || !walletClient) {
    throw new Error("A valid session and wallet client are required");
  }

  const res = await execute({
    sessionClient,
    walletClient,
    account,
    source,
    amount,
    tokenAddress,
  });

  if (res.isErr()) {
    throw res.error;
  }

  return res.value;
};