ERC20 Approval on Actions
Actions that spend Signer funds require ERC20 approval.
When executing action, a custom error SignerErc20ApprovalRequired can be returned which specifies that approval is required for a given token before action can be executed.
Approval is only required once for a given Signer/Token pair for authenticated in Account.
- TypeScript
- Graphql
- React
import { blockchainData, evmAddress, postId } from "@lens-protocol/client";import { executePostAction } from "@lens-protocol/client/actions";
const result = await prepareSignerErc20Approval(sessionClient, { approval: { inifinite: evmAddress("0x1234…"), }});
if (result.isErr()) { return console.error(result.error);}
As a reponse from prepare request you should recieve transaction request that should send via the user's wallet (SponsoredTransactionRequest or SelfFundedTransactionRequest).
viem
import { sendEip712Transaction, sendTransaction } from "viem/zksync/actions";import { walletClient } from "./viem";
await waitForTransactionReceipt(walletClient, { hash})
ethers
// coming soon