// set up target address and function signature abi
const targetContractAddress = "your target contract address";
const abi = ["function example()"];
const [address] = await window.ethereum!.request({
method: "eth_requestAccounts",
});
// generate payload using front-end provider such as MetaMask
const client = createWalletClient({
account: address,
chain,
transport: custom(window.ethereum!),
});
const chainId = await client.getChainId();
//encode function data
const data = encodeFunctionData({
abi: abi,
functionName: "example",
});